Flagship component v22.0.0

HTML to PDF Converter for .NET

ExpertPdf is an easy to use, yet powerful PDF library for .NET, with an HTML to PDF converter you can add to any .NET application in a few minutes.

Convert web pages, HTML files or HTML strings to PDF with HTML5, CSS3, SVG and JavaScript, headers and footers, page breaks, bookmarks and digital signatures.

One library · .NET Framework to .NET 11 C# & VB.NET samples included
Since 2007 · in business
Used by Thousands of companies worldwide · see customers
Targets .NET Framework to .NET 11

Everything the ExpertPdf HtmlToPdf Converter supports.

Twenty-four capabilities, grouped by where they act: how you give the converter its input, how the document is laid out, what comes out, and how the HTML is rendered.

Input

What the converter accepts.

URLs, HTML strings and local files, with or without authentication, rendered as screen or print media.

Convert a URL (web page) to PDF

Convert full web pages to PDF. The source can be a URL or a local HTML file.

Convert an HTML string to PDF

Convert raw HTML. Give a base URL when the HTML references external CSS files or images.

Convert authenticated pages

HTTP authentication with a user name and password, or a login form, by passing the session cookies to the converter.

Choose the CSS media type

Many websites have printer-friendly style sheets. Convert the page as rendered with @media print instead of the default @media screen.

Layout & paging

How the document is laid out.

Page size, orientation and margins, headers and footers, page breaks, part of a page, hidden elements, several pages in one PDF.

Page size and margins

Full control of the PDF page size, orientation and margins.

HTML headers and footers

Headers and footers on every PDF page, with full HTML support, images, text and page numbers.

Automatic and custom page breaks

Page breaks are inserted automatically without cutting lines of text or images. Add your own with the page-break-before and page-break-after CSS styles.

Convert part of a page

Convert only one section of the web page, given by an HTML element id or a CSS selector.

Hide elements during conversion

Leave out elements such as a Print button or a menu, chosen with CSS selectors.

The last page ends with the content

With the Chromium engine, the last page ends where the HTML content ends, with no trailing blank page or empty space.

Several pages in one PDF

Add several HTML pages to the same PDF, and merge existing PDF documents with the one being generated.

Output & PDF features

What comes out.

A file, a stream, bytes or a document object, with links, bookmarks, security, signatures and element positions.

Several output options

Write the PDF to a file or a stream, get it as a byte array, or get a PDF document object to change further.

HTML links kept

Links from the web page stay clickable in the PDF. You can also turn them off.

PDF bookmarks

Create bookmarks yourself, or generate them automatically from chosen tags or CSS classes of the page.

Digital signatures and security

Sign the PDF digitally, set user and owner passwords, and choose what readers may print, copy or change.

Accessible PDF (PDF/UA-1)

A tagged PDF, with the structure of the page, for screen readers and accessibility checks, with the Blink and Chromium engines.

PDF/A and PDF/X

PDF/A-1b, PDF/A-2b, PDF/A-3b, PDF/A-3u and PDF/A-3a documents for long-term archiving, and PDF/X-1a for print.

HTML element positions

Get where chosen HTML elements were placed in the PDF, for example where an image from the page ended up.

Rendering

How pages are drawn.

HTML5, CSS3, SVG and JavaScript, web fonts, a choice of engines and of when the conversion starts.

HTML5 and CSS3

HTML5, CSS3, JavaScript, canvas and SVG, rendered the way a browser shows them.

Web fonts (TTF, OTF, WOFF)

Locally installed TTF and OTF fonts, and web fonts in TTF or WOFF format.

Five rendering engines

Chromium (CEF 154) for modern pages, Blink (Chromium 148), the internal WebKit engine with no third-party dependencies, WebKit2 and, on .NET Framework, Internet Explorer, selected with one property.

Time limit and async methods

Cap how long one conversion may take with MaxConversionTime, and convert asynchronously with methods that take a cancellation token.

POST data, page ranges, offline mode

Send HTTP POST parameters with the request, convert only some pages, wait for a window status, convert without network access, and turn WebGL on when a page needs it.

Start: automatic, delayed or from JavaScript

Start the conversion when the page finishes loading, after a delay, or from a JavaScript call when your page decides it is ready.

Conversion options at a glance.

The main properties of the PdfConverter class. All of them are described in the API reference and used in the C# and VB.NET samples.

Property What it controls
PdfDocumentOptions.PdfPageSize The page size of the PDF: A4, Letter, Legal and the other standard sizes, or a custom size with CustomPdfPageSize.
PdfDocumentOptions.PdfPageOrientation Portrait or Landscape.
PdfDocumentOptions.LeftMargin · RightMargin · TopMargin · BottomMargin The page margins, in points.
PdfDocumentOptions.ShowHeader · PdfHeaderOptions A header on every page: text, images and HTML (AddHtmlToPdfArea), shown on the first, odd or even pages.
PdfDocumentOptions.ShowFooter · PdfFooterOptions A footer on every page, with the same content types and page numbers (ShowPageNumber, PageNumberingFormatString).
PageWidth · PageHeight The size, in pixels, of the browser window the HTML is laid out in.
RenderingEngine The engine that loads and renders the HTML: the new Chromium engine (CEF 154), recommended for modern pages, the Blink engine (Chromium 148), the internal WebKit engine, the default, with no third-party dependencies, and WebKit2 and, on .NET Framework, Internet Explorer.
MaxConversionTime A time limit, in seconds, for one conversion (60 by default).
ManagedContentTrimming With Chromium, the last page ends where the content ends, with no trailing blank page.
Tagged · Language A tagged, accessible PDF (PDF/UA-1) with the Blink and Chromium engines, in the given language.
RenderElementId · RenderElementSelector Convert only the part of the page inside the given element.
HtmlExcludedRegionsOptions Leave out elements matched by CSS selectors, for example a Print button or a menu.
UsePrintCSSMediaType Render the page with its @media print styles instead of @media screen.
ConversionDelay · StartupMode Wait a number of seconds after the page loads, or start the conversion from JavaScript when the page is ready.
AuthenticationOptions · HttpCookies · HttpHeaders Convert pages behind HTTP authentication or a login form, by passing credentials, cookies and headers.
PdfBookmarkOptions Create PDF bookmarks automatically from the HTML elements matched by CSS selectors.
PdfDocumentOptions.LiveUrlsEnabled · InternalLinksEnabled Keep the HTML links clickable in the PDF, or leave them out.
PdfSecurityOptions User and owner passwords, and the permissions to print, copy, edit and fill forms.
PdfDocumentOptions.AppendPDFFile · PrependPDFFile Add existing PDF documents before or after the converted content.

Released continuously since 2007.

The latest releases of the HTML to PDF Converter. The version history lists every release since version 2.0.

Version What changed
v22.0.0 · New Chromium rendering engine (CEF 154), for modern web pages, with its own NuGet packages: ExpertPdf.HtmlToPdf.Chromium.Windows and ExpertPdf.HtmlToPdf.NetCore.Chromium.Windows, with x64 variants. Blink rendering engine updated to Chromium 148, with a more robust start under load. Tagged, accessible PDF (PDF/UA-1) with the Blink and Chromium engines: Tagged and Language properties. PDF/A-2b, PDF/A-3b, PDF/A-3u and PDF/A-3a output. With Chromium, the last page ends where the content ends, with no trailing blank page (ManagedContentTrimming). A time limit for one conversion, on every engine except Internet Explorer: MaxConversionTime, 60 seconds by default. Asynchronous methods with cancellation for the PDF and image converters, such as GetPdfBytesFromUrlAsync (.NET Framework 4.0 and newer). Convert one element of the page chosen by a CSS selector (RenderElementSelector); an element that is not found is now reported as an error. New options: HTTP POST parameters, page ranges, window status, offline mode, WebGL (off by default) and AllowContentHeightResize. Automatic bookmarks and HTML element mapping with the Blink and Chromium engines. Security key size, accessibility copying, reading direction and header and footer visibility are now applied with the Blink, Chromium and Internet Explorer engines. Internal links are kept when a destination is malformed or its name is longer than 127 bytes. Version 22.0 requires a version 22 license key.
v21.1.0 · .NET 10 support. Speed improvements. Bug fixes.
v20.1.0 · Performance improvements. Bug fixes.
v19.0.0 · Performance improvements. Bug fixes.
v18.1.0 · Performance improvements. Bug fixes.

Full version history →

A few lines of code. URL to PDF.

Full C# and VB.NET samples for ASP.NET, ASP.NET MVC, ASP.NET Core Razor Pages and Windows Forms ship with the download. The documentation walks through the options.

Program.cs · C#
using ExpertPdf.HtmlToPdf;

var converter = new PdfConverter();
converter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
converter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait;
converter.PdfDocumentOptions.ShowFooter = true;
converter.PdfFooterOptions.ShowPageNumber = true;

// From a URL, or from HTML with GetPdfBytesFromHtmlString(html, baseUrl)
byte[] pdf = converter.GetPdfBytesFromUrl("https://www.example.com/");
File.WriteAllBytes("document.pdf", pdf);

Converter questions, answered.

Common questions about input, output, page control and rendering.

What can the converter take as input?
A URL, a local HTML file or an HTML string. For an HTML string, give a base URL so relative CSS, image and script paths resolve.
What output does it produce?
A PDF written to a file or a stream, returned as a byte array, or returned as a PDF document object you can change further before saving: add pages, text, images or a digital signature.
Are HTML links kept in the PDF?
Yes. Links to other sites stay clickable, and links to anchors in the page become links inside the PDF. Both can be turned off.
Can I control where page breaks fall?
Yes. The converter avoids breaking lines of text and images across pages, and you can force or avoid breaks with the CSS page-break-before, page-break-after and page-break-inside styles.
Can it convert pages that require a login?
Yes. Pass a user name and password for HTTP authentication, or the cookies of a logged-in session for a page behind a login form.
Does it support web fonts?
Yes. Fonts installed on the machine (TTF, OTF) and web fonts loaded by the page (TTF, WOFF) are rendered and embedded in the PDF.
Which rendering engines are included?
Five: the new Chromium engine (CEF 154), recommended for modern pages, the Blink engine (Chromium 148), the internal WebKit engine, the default, with no third-party dependencies, and WebKit2 and, on .NET Framework, Internet Explorer. Choose one with the RenderingEngine property. The Chromium engine comes in its own NuGet packages, ExpertPdf.HtmlToPdf.Chromium.Windows and ExpertPdf.HtmlToPdf.NetCore.Chromium.Windows.
Can it produce accessible or archive PDF documents?
Yes. With the Blink and Chromium engines, Tagged produces a tagged, accessible PDF (PDF/UA-1). PdfStandardSubset produces PDF/A-1b, PDF/A-2b, PDF/A-3b, PDF/A-3u and PDF/A-3a (tagged) and PDF/X-1a documents.
Is there an asynchronous API?
Yes. Methods such as GetPdfBytesFromUrlAsync, GetPdfBytesFromHtmlStringAsync and SavePdfFromUrlToFileAsync return a Task and take a cancellation token, on .NET Framework 4.0 and newer and on .NET Core and .NET 5 to .NET 11. MaxConversionTime limits how long one conversion may take.
Can I merge several HTML pages into one PDF?
Yes. Convert several pages into the same PDF document, and add existing PDF files before or after the converted content.
When does the conversion start?
When the page finishes loading, after a delay you set with ConversionDelay, or when your own JavaScript calls the converter, with StartupMode.Manual.

Try the converter free, or buy it today.

Download the free evaluation with C# and VB.NET samples for ASP.NET, ASP.NET MVC, ASP.NET Core Razor Pages and Windows Forms. When you are ready, license it on the pricing page.

Targets.NET Framework · .NET Core · .NET 5 to 11
Versionv22.0.0 · November 20, 2026