We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to use WindowStatus in WebKit HTML converter

Platform: ASP.NET MVC |
Control: PDF |
Published Date: November 24, 2017 |
Last Revised Date: April 16, 2019
Tags: htmltopdf, webkit

We can manually wait HtmlConverter up to the document loading using WindowStatus property in WebKit HTML converter. We can use windows status instead of addition delay. In additional delay, we do not know the exact time that need for execution of JavaScript. By windows status you can avoid this problem.

Note:

Both window status should be same, else converter never stops the conversion

Assemblies Required

  1. Syncfusion.Compression.Base.dll
  2. Syncfusion.HtmlConverter.Base.dll
  3. Syncfusion.Pdf.Base.dll
  4. QtBinaries folder

All the above mentioned assemblies can be get by installing the WebKit installer available in the below link.

WebKit HTML Converter: https://www.syncfusion.com/downloads/latest-version

C#

// Create a HTML to PDF converter object with default settings
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
WebKitConverterSettings webKitSettings = new WebKitConverterSettings();
 
//Set WebKitpath
webKitSettings.WebKitPath = @"../../../../QtBinaries";
 
//Set window status
webKitSettings.WindowStatus = "completed";
 
htmlConverter.ConverterSettings = webKitSettings;
 
//Convert url to pdf
PdfDocument document = htmlConverter.Convert("input.html");
 
//Save the document.
document.Save("Sample.pdf");

 

Input.html

<html>
<head>
 
</head>
<body >
    <div id="message">
        Wait for 2 Seconds
    </div>
   
    <script type="text/javascript">
        
        setTimeout(function () {
            document.getElementById("message").innerHTML = "Hello World!!";
            window.status = "completed";
        }, 2000);
    </script>
 
</body>
</html>

 

Working Sample can be downloaded from the below link.

http://www.syncfusion.com/downloads/support/directtrac/general/ze/WindowStatus1964014437

 

2X faster development

The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon