How to convert HTML to PDF
There are three common ways: a free online converter, your browser's Save as PDF, or a library that converts from your own application. Which one fits depends on whether you convert one page by hand or many documents automatically.
1. With a free online converter
Best for one document, now. Nothing to install.
- Open the free HTML to PDF converter (for HTML code) or the web page to PDF converter (for a URL).
- Paste the HTML, or enter the address of the page.
- Click Convert to PDF. The PDF downloads when it is ready.
The web page converter can only reach pages that are public on the internet.
2. With your browser
Every modern browser can save the page you are looking at as a PDF.
- Open the page or the HTML file in the browser.
- Choose Print (Ctrl+P, or Cmd+P on a Mac).
- As the printer, choose Save as PDF, then save.
The result follows the page's print styles, and the browser may add its own headers and footers. It is a manual step, one page at a time.
3. Automatically, from your .NET application
When documents are created by your software, such as invoices, reports or tickets, convert the HTML in code. The ExpertPdf HTML to PDF Converter converts a URL, an HTML file or an HTML string, with control over page size, margins, headers, footers and page breaks.
using ExpertPdf.HtmlToPdf; var converter = new PdfConverter(); // A web page converter.SavePdfFromUrlToFile("https://www.example.com/", "page.pdf"); // An HTML file converter.SavePdfFromHtmlFileToFile("report.html", "report.pdf"); // HTML code converter.SavePdfFromHtmlStringToFile("<h1>Hello</h1>", "hello.pdf");
Step by step: C#, VB.NET, ASP.NET, ASP.NET MVC.
Converting HTML to PDF: questions
What is the easiest way to convert HTML to PDF?
How do I convert an HTML file on my computer to PDF?
How do I convert HTML to PDF automatically?
Will links and page breaks be kept?
page-break-before, page-break-after and page-break-inside styles.Convert HTML to PDF from your application.
Download the free evaluation of the ExpertPdf HTML to PDF Converter, with C# and VB.NET samples.