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: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert HTML to PDF with Blink using C# and VB.NET

Platform: WinForms |
Control: PDF |
Published Date: April 29, 2019 |
Last Revised Date: January 14, 2020

The Syncfusion HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML to PDF using C#. It is reliable and accurate. The result preserves all graphics, images, texts, fonts, and the layout of the original HTML document or webpage. Using this library, you can convert a HTML to PDF in C# and VB.NET.

Converting HTML to PDF using Blink rendering engine using C# and VB.NET.

This tutorial explains how to convert the HTML to PDF  by using Blink rendering engine in a simple C# console application. In addition, Syncfusion HTML to PDF converter will work seamlessly in various platforms like WinForms, WPF, ASP.NET, ASP.NET MVC, and Azure Cloud service.

Steps to convert HTML to PDF using Blink rendering engine using C# and VB.NET:

  1. Create a new C# console application project.

Create a new project

  1. Install the Syncfusion.HtmlToPdfConverter.Blink.WinForms NuGet package as a reference to your .NET Framework application from NuGet.org.

Install HTML to PDF converter NuGet package

  1. Copy the BlinkBinaries folder from the HtmlToPdfConverter NuGet package installed location to bin folder of the project. You can place the BlinkBinaries other than bin folder, then it is mandatory to set the BlinkPath in BlinkConverterSettings explicitly.

Copy the QtBinaries folder from NuGet package folder

Paste the QtBinaries folder to the bin folder

  1. Include the following namespaces in the Program.cs file.

C#

using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;

 

VB.NET

Imports Syncfusion.HtmlConverter
Imports Syncfusion.Pdf

 

  1. Use the following code snippet to convert HTML to PDF in Blink.

C#

//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.Blink);
BlinkConverterSettings settings = new BlinkConverterSettings();
 
//Assign Blink settings to HTML converter
htmlConverter.ConverterSettings = settings;
 
//Convert HTML to PDF
PdfDocument document = htmlConverter.Convert("http://www.google.com/");
//Save and Close the PDF document 
document.Save("HTMLToPDF.pdf");
document.Close(true);
 
//This will open the PDF file so, the result will be seen in default PDF viewer
System.Diagnostics.Process.Start("HTMLToPDF.pdf");

VB.NET

'Initialize HTML to PDF converter 
Dim htmlConverter As HtmlToPdfConverter = New HtmlToPdfConverter(HtmlRenderingEngine.Blink)
Dim settings As BlinkConverterSettings = New BlinkConverterSettings()
'Assign Blink settings to HTML converter
htmlConverter.ConverterSettings = settings
'Convert URL to PDF
Dim document As PdfDocument = htmlConverter.Convert("http://www.google.com/")
'Save and Close the PDF document
document.Save("HTMLToPDF.pdf")
document.Close(True)
'This will open the PDF file so, the result will be seen in default PDF viewer
System.Diagnostics.Process.Start("HTMLToPDF.pdf")

You can download the working C#.NET sample from HTMLToPDF_Blink.Zip.

You can download the working VB.NET sample from HTMLToPDF_BlinkVB.Zip.

By executing the program, you will get the PDF document as follows.

Output screenshot

Take a moment to peruse the documentation, where you will find other options like HTML string to PDF, HTML to Image, HTML to single PDF page, and HTML to PDF conversion using WebKit Rendering with code examples.

Click here to explore the rich set of Syncfusion Essential PDF features.

To test the accuracy of HTML to PDF conversion in .NET using C#, try Syncfusion online demo.

2X faster development

The ultimate WinForms 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

Live Chat Icon For mobile
Live Chat Icon