HTML to PDF Conversion - WebKit Rendering Engine | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (172).NET Core  (29).NET MAUI  (192)Angular  (107)ASP.NET  (51)ASP.NET Core  (82)ASP.NET MVC  (89)Azure  (40)Black Friday Deal  (1)Blazor  (209)BoldSign  (12)DocIO  (24)Essential JS 2  (106)Essential Studio  (200)File Formats  (63)Flutter  (131)JavaScript  (219)Microsoft  (118)PDF  (80)Python  (1)React  (98)Streamlit  (1)Succinctly series  (131)Syncfusion  (882)TypeScript  (33)Uno Platform  (3)UWP  (4)Vue  (45)Webinar  (49)Windows Forms  (61)WinUI  (68)WPF  (157)Xamarin  (161)XlsIO  (35)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (8)Business intelligence  (55)Button  (4)C#  (146)Chart  (125)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (62)Development  (613)Doc  (7)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (5)Essential Tools  (14)Excel  (37)Extensions  (22)File Manager  (6)Gantt  (18)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (488)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (41)Performance  (12)PHP  (2)PivotGrid  (4)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (52)Security  (3)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (10)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (112)UI  (368)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (30)Visual Studio Code  (17)Web  (577)What's new  (313)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)

HTML-to-PDF Conversion Using WebKit Rendering Engine

Syncfusion Essential PDF now supports HTML-to-PDF conversion using the WebKit rendering engine in addition to existing Internet Explorer and Blink renderers. This converter works well on both x86 and x64 environments.

Essential PDF can be easily integrated into any application on .NET platforms—such as Windows Forms, WPF, ASP.NET, and ASP.NET MVC—to convert URLs, HTML strings, images, and SVGs to PDFs. The WebKit rendering engine provides better support to render modern web standards, so the output of the WebKit engine is more accurate in some cases than that of other rendering engines.

Syncfusion HTML-to-PDF converter can convert any URL to a PDF.

Limitations in the Internet Explorer Rendering Engine

Till now, Syncfusion’s HTML-to-PDF converter relied on Microsoft’s MSHTML library to perform conversions. The conversion happens in two steps: First, HTML is converted into a metafile, and then the metafile is converted to PDF. The main advantage of this is that the text rendered remains searchable in PDF. This is an extremely important requirement for a lot of our customers.

However, with version 9 of Internet Explorer, Microsoft started using hardware acceleration to produce bitmap images instead of metafiles while retrieving snapshots, completely removing the ability to render selectable or searchable text within a PDF document. Users worked on this problem by making registry changes but were not satisfied with the result, so a better alternative was needed.

After considerable research, a new converter based on the WebKit renderer was created.

The documents rendered using WebKit contain vector graphics instead of scalar images. This reduces file size and allows users to perform various operations such as searching, selecting, and copying text to the clipboard. Apart from overcoming the limitations in the Internet Explorer rendering engine, the new WebKit render also provides better support to render HTML5, CSS3, and SVG content.

A to Z about Syncfusion’s versatile HTML-to-PDF converter and its rich feature set.

Rendering Engine Comparison

Refer to “Supported and Unsupported Features by Rendering Engines” in Syncfusion’s documentation to compare various rendering engines and to learn about the features they support.

Prerequisites

You can get the required assemblies and QtBinaries by installing the Syncfusion.HtmlToPdfConverter.QtWebKit.WinForms NuGet package in your application. You can also get the required files by installing the HTML converter. Refer to “Steps to Download the HTML Converter Installer” in Syncfusion’s documentation to download the HTML converter installer.

The WebKit HTML converter requires VC++ 2010 redistributables (msvcp100.dll, msvcr100.dll) for converting webpages to PDF; hence, these assemblies should be available in the machine. For 64-bit machines, place the assembly in C:\Windows\SysWOW64\. For 32-bit machines, place the assembly in C:\Windows\System32\.

For converting HTTPS sites to PDF, the WebKit HTML converter requires OPENSSL assemblies (libeay32.dll, libssl32.dll, ssleay32.dll). These assemblies should be available in the machine. For 64-bit machines, place the assembly in C:\Windows\SysWOW64\. For 32-bit machines, place the assembly in C:\Windows\System32\.

The WebKit converter may create a blank-page PDF in the following cases:

  • When the webpage (HTML/URL) is not available or accessible.
  • When OPENSSL assemblies are missing in the machine where the conversion takes place.

Refer to “Prerequisites for Windows” in Syncfusion’s documentation to learn more about the prerequisites for converting HTML to PDF with the WebKit rendering engine.

The following procedure explains how to convert a webpage using the WebKit renderer:

  1. Create an instance of the HtmlToPdfConverter class with the WebKit rendering engine.
    //Initialize HTML-to-PDF converter with WebKit rendering engine.
    HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);
    
  2. Create an instance of the WebKitConverterSettings class to set the conversion settings.
    //Initialize WebKit converter settings.
    WebKitConverterSettings settings = new WebKitConverterSettings();
    
  3. Set the absolute or relative path of the QtBinaries folder to the WebKitPathproperty of WebKitHtmlConverter. Refer to “Conversion Using WebKit Rendering” in Syncfusion’s documentation to learn more about WebKit settings.
    //Set WebKitPath.
    Setting.WebKitPath = @"/QtBinaries/"
    
  4. Assign WebKitConverterSettings to the HtmlToPdfConverter conversion settings.
    // Assign WebKit settings to HTML converter.
    htmlConverter.ConverterSettings = settings;
    
  5. Convert the URL to PDF using the Convert method in HtmlToPdfConverter.
    //Convert URL to PDF.
    PdfDocument document = htmlConverter.Convert("http://www.google.com");
  6. Save the PDF document to disk and dispose of the object. The following code sample is used to save the PDF document.
    //Save and close the PDF document.
    document.Save("Output.pdf");
    document.Close(true);

You can download a working sample from “Conversion Using WebKit Rendering” in Syncfusion’s documentation.

Take a moment to peruse our documentation where you can find other conversion options, with code examples, such as HTML string to PDFpartial webpage to PDFHTML to a single PDF page, and HTML to PDF using IE rendering.

Refer to the homepage for Essential PDF to explore the rich set of PDF library features.

Syncfusion’s high-performance PDF Library allows you to create PDF documents from scratch without Adobe dependencies.

Tags:

Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed
Scroll To Top