HTML5, CSS3 and JavaScript
Flexbox and grid, web fonts, SVG, canvas and modern JavaScript frameworks; wait for the page, inject CSS and JavaScript.
Convert web pages, HTML strings and HTML files to PDF from C# and VB.NET on Windows, Linux and macOS, in Docker containers and in the cloud. Chromium, the engine of the Chrome browser, renders HTML5, CSS3, web fonts and JavaScript, and the PDF keeps the look of the page, with selectable text, live links and embedded fonts.
The HTML to PDF converter is part of ExpertPdf Anywhere, the .NET library with every ExpertPdf tool. The engine ships in the NuGet packages: nothing to install on the server, no system packages on Linux.
Documentation · Online samples · NuGet · Download .zip (v22.0.0) · HTML to PDF docs · URL to PDF online sample
How the HTML is rendered, how the pages are laid out, what the PDF document carries, and where it runs.
Chromium loads the page, runs its JavaScript, then the PDF is built from the rendered page.
Flexbox and grid, web fonts, SVG, canvas and modern JavaScript frameworks; wait for the page, inject CSS and JavaScript.
To PDF bytes, a file, a stream, or a document you change before saving. The same sources to PNG, JPEG, BMP and TIFF images.
HTTP authentication, login forms, cookies, HTTP headers and POST data.
Convert one element chosen by a CSS selector, or leave elements out.
Pages, headers and footers, bookmarks and links.
Page size, orientation and margins, page breaks, keep-together blocks and repeated table headers.
Text, images, HTML or Word documents, with page numbers.
Built from the headings of the page, with page numbers and links; internal and web links stay live.
HTML forms converted to fillable PDF form fields, and the position in the PDF of any HTML element.
The standards and options of the PDF the converter writes.
Tagged, accessible PDF/UA-1 and PDF/UA-2 documents.
PDF/A-1a, 1b, 2a, 2b, 2u, 3a, 3b, 3u, 4, 4e and 4f, and PDF/X-1a, with associated files.
ZUGFeRD and Factur-X invoices from an HTML invoice.
Passwords and permissions; add text, images, HTML and digital signatures to the converted document.
The engine ships with your application, for each platform.
The engine is loaded once and kept ready, with no process started for each conversion; or each conversion in a process of its own.
One converter per conversion, up to 8 at the same time by default; asynchronous methods with cancellation.
Linux images with nothing installed; Azure, AWS and Google Cloud Run, each with a tested setup.
Conversions in the ExpertPdf engine container instead of on the application's machine, which is also how Alpine Linux converts. See remote engine.
Create a PdfConverter from ExpertPdf.Anywhere.HtmlToPdf, set the options and call one conversion method. The tabs convert a URL with page numbers, an HTML string to an accessible PDF/UA document, and several pages at the same time.
using ExpertPdf.Anywhere.HtmlToPdf; var converter = new PdfConverter(); // converter.LicenseKey = "your license key"; // A4 pages, the page laid out in a 1024 pixels wide browser window converter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4; converter.PdfDocumentOptions.PdfPageOrientation = PDFPageOrientation.Portrait; converter.PageWidth = 1024; // Page numbers in the footer converter.PdfDocumentOptions.ShowFooter = true; converter.PdfFooterOptions.ShowPageNumber = true; converter.SavePdfFromUrlToFile("https://www.example.com/", "page.pdf");
Install the package of your operating system, dotnet add package ExpertPdf.Anywhere.Windows
(or .Linux, .Linux.Arm64, .MacOS); it brings the ExpertPdf Anywhere library with it. The
HTML to PDF overview and the
features describe every option, and the online samples convert
a URL,
HTML code and
an accessible PDF.
Windows only, or .NET Framework? See the classic HTML to PDF Converter. Moving from wkhtmltopdf? See the wkhtmltopdf alternative.
Also in ExpertPdf Anywhere: Word to PDF, Excel to PDF, PowerPoint to PDF, PDF to Word, PDF to Excel, PDF to PowerPoint, and every other ExpertPdf tool.
Common questions about platforms, deployment, standards and licensing.
PdfConverterConcurrencyLevel sets how many HTML conversions run at the same time in the application, 8 by default; the others wait their turn. The asynchronous methods, such as GetPdfBytesFromUrlAsync, take a cancellation token.ChromiumEngineHostMode.OutOfProcess), so a failure inside the engine cannot affect the application, or in the ExpertPdf engine container (the remote engine).AccessibilityStandard produces tagged PDF/UA-1 and PDF/UA-2 documents, and PdfStandardSubset PDF/A-1a, 1b, 2a, 2b, 2u, 3a, 3b, 3u, 4, 4e and 4f, and PDF/X-1a. ZUGFeRD and Factur-X electronic invoices are supported too.ExpertPdf.Anywhere.Fonts package.PdfConverter class, in the ExpertPdf.Anywhere.HtmlToPdf namespace, and runs on Windows, Linux and macOS with Chromium. See migrating to Anywhere.Install ExpertPdf Anywhere from NuGet and try every feature in evaluation mode. License it on the pricing page when you are ready.