HTML to PDF Converter Overview |
The HTML to PDF converter of ExpertPdf Anywhere converts web pages, HTML strings and HTML files to PDF documents and to images. It is part of the ExpertPdf.Anywhere library, which runs on .NET 8, .NET 9, .NET 10 and .NET 11 and on every framework that runs .NET Standard 2.0 libraries (.NET Framework 4.6.1 and later), on Windows (x64 and x86), Linux (x64 and ARM64) and macOS (Apple Silicon): ASP.NET Core and ASP.NET applications, console applications, services, desktop applications, containers and cloud functions. No printer driver is used. See Requirements.
The converter renders the HTML with Chromium, the engine of the Chrome browser - HTML5, CSS3, web fonts and JavaScript - and preserves the look of the page in the PDF, with selectable and searchable text, live links and embedded fonts. The engine ships in the NuGet packages, next to the application; it runs inside the application by default, or in a process of its own for each conversion. Report pages of your own application, with their charts, grids and styles, become PDF documents with a few lines of code.
Install the platform package of the machine that runs the application, for example ExpertPdf.Anywhere.Windows or ExpertPdf.Anywhere.Linux (see Installation), then:
using ExpertPdf.Anywhere.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 and more - see Getting started and Features.
Converts a URL, an HTML string, an HTML file or an HTML stream to PDF bytes, a file, a stream, or a Document you can change before saving. See PdfConverter class.
Converts the same sources to PNG, JPEG, BMP or TIFF images. See ImgConverter class.
Asynchronous conversion methods with cancellation. See Asynchronous Conversions.
Headers and footers with text, images, HTML, Word documents and page numbers. See Headers and footers.
Bookmarks, internal links and a table of contents with page numbers built from the headings of the page. See Automatic bookmarks.
PDF/A, PDF/X-1a, tagged PDF, PDF/UA-1 and PDF/UA-2. See PDF standards and Tagged PDF and accessibility.
ZUGFeRD / Factur-X electronic invoices. See Electronic invoices.
HTML forms converted to fillable PDF form fields - see HTML Forms to PDF Form Fields.
The position in the PDF of any HTML element. See HTML elements mapping.
HTML added anywhere in a PDF document, next to text, images and shapes. See HTML to PDF element.