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. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to convert HTML to PDF in ASP.NET Core Windows?

Platform: ASP.NET Core |
Control: PDF

Syncfusion HTML to PDF for .NET used to convert webpages, SVG, MHTML, and HTML to PDF. Using this library, you can convert HTML to PDF in ASP.NET Core Windows.

Steps to convert HTML to PDF in ASP.NET Core Windows programmatically:

  1. Create a new ASP.NET Core MVC application. Create new ASP.NET Core MVC application
  2. Install the Syncfusion.HtmlToPdfConverter.QtWebKit.Net.Core NuGet package as reference to your .NET Core application from NuGet.org Install required Nuget packages
  3. Copy the QtBinariesWindows folder from the installed HtmltoPdfConverter package and paste it into the folder, which contains the HTMLtoPDF_Windows.csproj file. QtBinariesWindows path location Paste location for QtBinaries Windows
  4. Then, set Copy to output directory to copy all the QtBinariesWindows (all files including inner folders and files) assemblies. Paste location for QtBinaries Windows
  5. Add an Export To PDF button in index.cshtml. Paste location for QtBinaries Windows
  6. Include the following namespaces and code snippet for converting HTML to PDF in ASP.NET Core Windows.


using Syncfusion.HtmlConverter;
using Syncfusion.Pdf;
using System.IO;
using Microsoft.AspNetCore.Hosting;


//To get content root path of the project
private readonly IHostingEnvironment _hostingEnvironment;
public HomeController(IHostingEnvironment hostingEnvironment)
   _hostingEnvironment = hostingEnvironment;
public IActionResult ExportToPDF()
//Initialize HTML to PDF converter 
HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter();
WebKitConverterSettings settings = new WebKitConverterSettings();
//Set WebKit path
settings.WebKitPath = Path.Combine(_hostingEnvironment.ContentRootPath, "QtBinariesWindows");
//Assign WebKit settings to HTML converter
htmlConverter.ConverterSettings = settings;
//Convert URL to PDF
PdfDocument document = htmlConverter.Convert("https://www.google.com");
MemoryStream stream = new MemoryStream();
return File(stream.ToArray(),   System.Net.Mime.MediaTypeNames.Application.Pdf, "Output.pdf");
  1. Build and run the application, the website will open in the browser, then, you can export HTML to PDF. Run the application, opened in website
  2. By exporting HTML to PDF, you will get the PDF document as follows. Output PDF document screenshot

A complete working sample can be downloaded from HTMLtoPDF_Windows.zip

Take a moment to peruse the documentation for Converting HTML to PDF, where you will find various options for URL to PDF, HTML string to PDF, and hyperlinks.

2X faster development

The ultimate ASP.NET Core UI toolkit to boost your development speed.
You must log in to leave a comment
Hasibul Islam Shanto
May 18, 2020

trail version or open source?

Sowmiya Loganathan [Syncfusion]
May 18, 2020

Hi Hasibul,

The HTML converter alone, does not requires any licensing. We are providing separate HTML converter add-on for file format licensing. Please refer below links to install the HTML converter installer.

UG: https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf#steps-to-download-the-html-converter-installer


Sowmiya L

Dec 08, 2020

hi Is it possible to put headers and footers for all pages?

Gowthamraj Kumar [Syncfusion]
Dec 09, 2020

Hi yeadam,

Thank you for contacting Syncfusion support.

Currently, our HTML converter does not have direct support for adding a header/footer from the HTML file. As a workaround, we can convert each HTML data (Header, body (actual HTML), footer) to PDF separately and then draw it in the new PDF document as it looks like the header and footer are added. Can you please refer to the below link for adding HTML as header and footer in PDF while converting HTML to PDF (Net Framework),

KB (as HTML): https://www.syncfusion.com/kb/8196/how-to-add-html-as-header-and-footer-in-pdf-while-converting-html-to-pdf

KB: https://www.syncfusion.com/kb/8381/how-to-add-pdf-header-and-pdf-footer-while-converting-html-to-pdf

Please let us know if you need any further assistance on this.


Gowthamraj K

Jul 27, 2021

I am getting blank page as pdf output, in .net core 3.1 and binaries are 19. something, same code.

Gowthamraj Kumar [Syncfusion]
Jul 28, 2021

Hi Manoj,

Thank you for contacting Syncfusion support.

Our HTML converter may generate blank PDFs while converting HTTPS sites to PDF. For converting HTTPS sites to PDF, the WebKit rendering engine requires OPENSSL libraries. So, please make sure the OPENSSL assemblies are available in the machine where the conversion takes place. Please refer to the below links for more details,

Prerequisites - https://help.syncfusion.com/file-formats/pdf/convert-html-to-pdf/webkit#openssl

Troubleshooting - https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf#troubleshooting

However, the below mentioned OPENSSL assemblies can be placed in the Windows system folder of the machine. (for 64-bit machine, it should be place in $SystemDrive\Windows\SysWOW64 and for 32-bit machine, it should be place in $SystemDrive\Windows\System32).
• libeay32.dll • libssl32.dll • ssleay32.dll

If you running the application in docker, you can copy and paste the OPENSSL assemblies files inside the QtBinaries folder in your application.

Kindly try the conversion with OPENSSL assemblies and let us know the result.


Gowthamraj K

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