Click or drag to resize

ExpertPdf HTML to PDF Converter for .NET

ExpertPdf HTML to PDF Converter for .NET converts web pages, HTML strings and HTML files to PDF documents and to images. It is a library you reference from any .NET Framework, .NET Core or .NET 5 - .NET 11 application - ASP.NET Core, ASP.NET Web Forms and MVC, Windows Forms, WPF, console applications, services. Nothing has to be installed on the server, and no printer driver is used.

The converter renders the HTML like a browser - with the Chromium, Blink or WebKit rendering engine - and preserves the look of the page in the PDF, with selectable text, live links and embedded fonts. Report pages of your own application, with their charts, grids and styles, become PDF documents with a few lines of code.

Quick start

Install the ExpertPdf.HtmlToPdf.NetCore NuGet package (or reference ephtmltopdf.dll from the download, see Installation), then:

using ExpertPdf.HtmlToPdf;

PdfConverter converter = new PdfConverter();
converter.LicenseKey = "your license key";

// a web page to a PDF file
converter.SavePdfFromUrlToFile("https://www.example.com", "page.pdf");

// an HTML string to a PDF document in memory (to send it to a browser, store it, attach it to an email...)
byte[] pdfBytes = converter.GetPdfBytesFromHtmlString("<h1>Hello</h1><p>From ExpertPdf</p>");

The default settings suit most documents. The converter has many options to control the result: the page size, orientation and margins, headers and footers, page breaks, bookmarks, security, the PDF standard, the rendering engine and more - see Getting started and Features.

What's new in version 22.0
  • The Chromium rendering engine (Chromium 154), the recommended engine for modern pages. See Rendering engines.

  • The Blink rendering engine is updated to Chromium 148 and starts more robustly under load.

  • Tagged, accessible PDF and PDF/UA. See Tagged PDF and accessibility.

  • PDF/A-2b, PDF/A-3b, PDF/A-3u and PDF/A-3a, and associated files. See PDF standards.

  • ZUGFeRD / Factur-X electronic invoices. See Electronic invoices.

  • Automatic bookmarks and HTML elements location with the Blink and Chromium engines.

  • New conversion options: HttpPostParameters, SecureProtocol, RenderElementSelector, PageRanges, WindowStatus, EnableOfflineMode, WebGlEnabled, AllowContentHeightResize.

  • With Chromium, the last page ends where the content ends (no trailing blank page): ManagedContentTrimming and ManagedContentTrimmingMode. See Where the last page ends.

  • MaxConversionTime limits the time of a conversion with every engine; RenderOnTimeout also works with Chromium. See Timeouts.

  • Asynchronous conversion methods with cancellation (GetPdfBytesFromUrlAsync and the others). See Asynchronous methods.

  • Partial conversion of an element that does not exist fails with an error instead of converting the whole page (Chromium and Blink).

  • HtmlToPdfElement continues on the next pages with Chromium, and maps HTML elements with Chromium and Blink. See HTML to PDF element.

  • Table of contents with page numbers and links, page labels and named destinations. See Document class.

Version 22.0 adds members without changing the existing ones, so code written for earlier versions keeps working. It needs a version 22 license key.

See Also