Your account has not been activated. Click here to get a new activation Email.
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 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 string, SVG, and MHTML to PDF, and also convert other formats like HTML to MHTML, HTML to SVG, and HTML to image.

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

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

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


PDF Sample

Here are some samples documents created using Syncfusion HTML to PDF conversion.


Features

  • Converts any webpage to PDF.
  • Converts any raw HTML string to PDF.
  • Prevents text and image split across pages.
  • Converts HTML form to fillable PDF form.
  • Works both in 32-bit and 64-bit environments.
  • Automatically creates table of contents.
  • Automatically creates bookmark hierarchy.
  • Converts only a part of the webpage to PDF.
  • Supports header and footer.
  • Repeats HTML table header and footer 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.
  • Thread safe.
  • Supports internal and external hyperlinks.
  • Sets document properties, page settings, security, viewer preferences, etc.
  • Protects PDF documents with passwords and permissions.

Installation

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

$Systemdrive\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 below 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 below 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: http://help.syncfusion.com/file-formats/pdf/working-with-document-conversions#conversion-using-webkit-rendering

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.