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:
- 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);
- Create an instance of the WebKitConverterSettings class to set the conversion settings.
//Initialize WebKit converter settings. WebKitConverterSettings settings = new WebKitConverterSettings();
- 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/"
- Assign WebKitConverterSettings to the HtmlToPdfConverter conversion settings.
// Assign WebKit settings to HTML converter. htmlConverter.ConverterSettings = settings;
- Convert the URL to PDF using the Convert method in HtmlToPdfConverter.
//Convert URL to PDF. PdfDocument document = htmlConverter.Convert("http://www.google.com");
- 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 PDF, partial webpage to PDF, HTML 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.