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.
Unfortunately, activation email could not send to your email. Please try again.

HTML to PDF for .NET

Syncfusion Essential PDF supports HTML to PDF conversion by using the advanced Qt WebKit rendering engine. This converter 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, SVG, and MHTML to PDF, as well as other formats like HTML to MHTML, HTML to SVG, and HTML to an image.

Essential PDF is reliable and provides full support for HTML tags, CSS, JavaScript, and also advanced HTML5 features like CSS3, Canvas, SVG, and web fonts.

Essential PDF WebKit rendering is accurate, and the result preserves all graphics, images, texts, fonts, and the layout of the original HTML document or webpage.

It does not require external dependencies like browsers, printer drivers, or viewers.


HTML to PDF Sample

The following sample documents were created using Syncfusion HTML to PDF conversion.


Features

  • Converts any webpage to PDF.
  • Converts any raw HTML string to PDF.
  • Prevents text and images from splitting across pages.
  • Converts HTML forms to fillable PDF forms.
  • Works both in 32-bit and 64-bit environments.
  • Automatically creates a table of contents.
  • Automatically creates bookmark hierarchy.
  • Can convert only a part of a webpage to PDF.
  • Supports headers and footers.
  • Repeats HTML table headers and footers in PDF.
  • Supports HTML5, CSS3, SVG, and web fonts.
  • Converts any HTML to MHTML.
  • Converts any HTML to SVG.
  • Converts any HTML to an image.
  • Supports accessing HTML pages using both HTTP POST and GET methods.
  • Supports HTTP cookies.
  • Supports cookie-based form authentication.
  • Is thread safe.
  • Supports internal and external hyperlinks.
  • Sets document properties, page settings, security, viewer preferences, and more.
  • Protects PDF documents with passwords and permissions.

Installation

  1. You can download the WebKit HTML converter here:
  2. To convert HTML to PDF in your application using the WebKit rendering engine, the following assemblies need to be added as references to the project:
    • Syncfusion.Compression.Base.dll
    • Syncfusion.Pdf.Base.dll
    • Syncfusion.HtmlConverter.Base.dll
  3. After installation, the WebKitPath property of an instance of the WebKitConverterSettings class should be assigned to the QtBinaries directory in the installed location. By default, this will be the installed location.

$System drive\Program Files (x86)\Syncfusion\WebKitHTMLConverter\xx.x.x.xx\QtBinaries

Alternatively, you can place the QtBinaries folder in the application bin folder, which needs no reference in the code.


Getting Started

Converting a URL to a PDF Document

To convert a website URL or a local HTML file to PDF using the WebKit rendering engine, please refer to the following code snippet.

//Initialize HTML to PDF converter

HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);

//Convert HTML to PDF document

PdfDocument document = htmlConverter.Convert("http://www.google.com");

//Save and close the PDF document

document.Save("Output.pdf");

document.Close(true);

Converting an HTML String to a PDF Document

To convert an HTML string to PDF, use the following code snippet.

//Initialize HTML to PDF converter

HtmlToPdfConverter htmlConverter = new HtmlToPdfConverter(HtmlRenderingEngine.WebKit);

//HTML string and Base URL(base path of the additional resource like CSS, JS)

string htmlText = @"<html><body>Hello World!!!</body></html>";

string baseUrl = "";

//Convert HTML to PDF document

PdfDocument document = htmlConverter.Convert(htmlText, baseUrl);

//Save and close the PDF document

document.Save("Output.pdf");

document.Close(true);

Documentation is also available at: https://help.syncfusion.com/file-formats/pdf/converting-html-to-pdf

Class reference documentation is available at: https://help.syncfusion.com/cr/cref_files/file-formats/pdf/Syncfusion.HtmlConverter.Base~Syncfusion.HtmlConverter_namespace.html


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.