| title | HTML to PDF conversion in .NET PDF Library | Syncfusion |
|---|---|
| description | Discover how to convert HTML to PDF using the Blink rendering engine, with various features like TOC, partial web page to PDF, and more. |
| platform | document-processing |
| control | |
| documentation | UG |
The HTML to PDF converter is a .NET library for converting webpages, SVG, MHTML, and HTML files to PDF using C#. It uses popular rendering engines such as Blink (Google Chrome) and is reliable and accurate. The result preserves all graphics, images, text, fonts, and the layout of the original HTML document or webpage.
Syncfusion® HTML-to-PDF converter will work seamlessly in various platforms like Azure Cloud or web apps, Azure Functions, Amazon Web Service (AWS), Docker, WinForms, WPF, ASP.NET MVC, ASP.NET Core with Windows, Linux, and macOS.
- Converts any webpage to PDF.
- Converts any raw HTML string to PDF.
- Converts HTML form to fillable PDF form.
- Automatically creates Table of Contents.
- Automatically creates bookmark hierarchy.
- Converts only a part of the web page to PDF.
- Supports PDF header and PDF footer.
- Repeats HTML table header and footer in PDF.
- Supports HTML5, CSS3, SVG, and Web fonts.
- Converts any HTML to an image.
- Converts any SVG to image.
- Supports accessing HTML pages using both HTTP POST and GET.
- Supports cookies-based form authentication.
- Thread safe.
- Supports internal and external hyperlinks.
- Sets document properties, page settings, security, viewer preferences, and more.
- Protects PDF document with password and permission.
- Compatible with .NET Framework 4.5 and above.
- Compatible with .NET Core 2.0 and above.
Include the HTML to PDF converter in your project using two approaches.
- NuGet packages (Recommended)
- Assemblies.
Directly install the NuGet packages to your .NET application from nuget.org.
N> The HTML to PDF converter library internally uses the Blink rendering engine for the conversion. The binaries will differ for Windows, Linux, Mac, and AWS. So, separate packages are provided based on OS. Include the packages based on your requirement.
| Platform(s) | NuGet Package |
|---|---|
| (.NET Core, .NET 8, .NET 9) Windows | {{'[Syncfusion.HtmlToPdfConverter.Net.Windows.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Windows/)'| markdownify }} |
| (.NET Core, .NET 8, .NET 9) Linux | {{'[Syncfusion.HtmlToPdfConverter.Net.Linux.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Linux/)'| markdownify }} |
| (.NET Core, .NET 8, .NET 9) Mac | {{'[Syncfusion.HtmlToPdfConverter.Net.Mac.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Mac/)'| markdownify }} |
| (.NET Core, .NET 8, .NET 9) AWS | {{'[Syncfusion.HtmlToPdfConverter.Net.Aws.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Net.Aws/)'| markdownify }} |
Use the following packages for .NET Framework targeted applications. If you are using other Syncfusion libraries or components, use the HTML to PDF converter library with the same platform packages.
| Platform(s) | NuGet Package |
|---|---|
| Windows Forms | {{'[Syncfusion.HtmlToPdfConverter.WinForms.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.WinForms/)'| markdownify }} |
| WPF | {{'[Syncfusion.HtmlToPdfConverter.Wpf.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.Wpf/)'| markdownify }} |
| ASP.NET | {{'[Syncfusion.HtmlToPdfConverter.AspNet.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet/)'| markdownify }} |
| ASP.NET MVC | {{'[Syncfusion.HtmlToPdfConverter.AspNet.Mvc5.nupkg](https://www.nuget.org/packages/Syncfusion.HtmlToPdfConverter.AspNet.Mvc5/)'| markdownify }} |
Get the following required assemblies by downloading the HTML converter installer. Download and install the HTML converter for Windows, Linux, and Mac, respectively. Please refer to the advanced installation steps for more details.
| Platforms | Assemblies |
|---|---|
| WinForms WPF ASP.NET ASP.NET MVC |
|
| .NET/.NET Core Blazor |
|
Integrating HTML to PDF converter library in any .NET application is simple. Please refer to the following steps to include HTML to PDF conversion in your application.
Steps to convert HTML to PDF in .NET application
Step 1: Create a new .NET console application.

Step 2: Install Syncfusion.HtmlToPdfConverter.Net.Windows NuGet package as a reference to your .NET application from NuGet.org.

Step 3: Include the following namespace in your class file.
{% highlight c# tabtitle="C#" %}
using Syncfusion.Pdf; using Syncfusion.HtmlConverter;
{% endhighlight %}
Step 4: Use the following code sample to convert the URL to PDF in the program.cs.
{% tabs %}
{% highlight c# tabtitle="C#" %}
//Initialize HTML to PDF converter. HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(); BlinkConverterSettings blinkConverterSettings = new BlinkConverterSettings(); //Set Blink viewport size. blinkConverterSettings.ViewPortSize = new Syncfusion.Drawing.Size(1280, 0); //Assign Blink converter settings to HTML converter. htmlConverter.ConverterSettings = blinkConverterSettings; //Convert URL to PDF document. PdfDocument document = htmlConverter.Convert("https://www.syncfusion.com"); //Create a filestream. FileStream fileStream = new FileStream("HTML-to-PDF.pdf", FileMode.CreateNew, FileAccess.ReadWrite); //Save and close the PDF document. document.Save(fileStream); document.Close(true);
{% endhighlight %}
{% endtabs %}
By executing the program, you will get the PDF document as follows.

A complete working sample can be downloaded from Github.
HTML to PDF converter .NET library supports conversion in Linux. Refer to this section for more information about HTML to PDF conversion in Linux.
HTML to PDF converter .NET library supports conversion in Docker. Refer to this section for more information about HTML to PDF conversion in Docker.
HTML to PDF converter .NET library supports conversion in Mac. Refer to this section for more information about HTML to PDF conversion in Mac.
HTML to PDF converter .NET library supports conversion in ASP.NET Core. Refer to this section for more information about HTML to PDF conversion in ASP.NET Core.
HTML to PDF converter .NET library supports conversion in ASP.NET MVC. Refer to this section for more information about HTML to PDF conversion in ASP.NET MVC.
HTML to PDF converter .NET library supports conversion in Blazor. Refer to this section for more information about HTML to PDF conversion in Blazor.
HTML to PDF converter .NET library supports conversion in Azure. Refer to this section for more information about HTML to PDF conversion in Azure.
HTML to PDF converter .NET library supports conversion in AWS. Refer to this section for more information about HTML to PDF conversion in AWS.
Refer to this section for more information about features in HTML to PDF converter, you can get the details, code examples and demo from this section.
Refer to this section for troubleshooting HTML to PDF conversion failures and frequently asked questions.
By default, the PDF document generated with the IE rendering engine comes with the following warning message.
Please refer to the below code snippet to use the DisableIEWarning API to remove the default IE warning from the PDF document.{% tabs %}
{% highlight c# tabtitle="C#" %}
//Initialize the HTML to PDF converter
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.IE);
IEConverterSettings settings = new IEConverterSettings();
//Disable Default IE warning message.
settings.DisableIEWarning = true;
//Assign IE settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
//Save and close the PDF document document.Save("Output.pdf"); document.Close(true);
{% endhighlight %}
{% highlight vb.net tabtitle="VB.NET" %} 'Initialize the HTML to PDF converter Dim htmlConverter As New HtmlToPdfConverter(HtmlRenderingEngine.IE) Dim settings As New IEConverterSettings() 'Disable Default IE Warning Message settings.DisableIEWarning = true 'Assign IE settings to HTML converter htmlConverter.ConverterSettings = settings 'Convert URL to PDF Dim document As PdfDocument = htmlConverter.Convert("https://www.google.com")
'Save and close the PDF document document.Save("Output.pdf") document.Close(True)
{% endhighlight %}
{% highlight c# tabtitle="ASP.NET Core" %} //Currently, IE rendering engine does not support conversion in .NET Core platform {% endhighlight %}
{% endtabs %}
N>Please try our Blink engine to improve the quality and accuracy of the HTML to PDF conversion.

