Guide

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.

  1. Open the free HTML to PDF converter (for HTML code) or the web page to PDF converter (for a URL).
  2. Paste the HTML, or enter the address of the page.
  3. 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.

  1. Open the page or the HTML file in the browser.
  2. Choose Print (Ctrl+P, or Cmd+P on a Mac).
  3. 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.

Convert.cs · C#
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?
For HTML code, paste it into the free HTML to PDF converter; for a web page, enter its address in the web page to PDF converter. Both are free and need no sign-up.
How do I convert an HTML file on my computer to PDF?
Open the file in your browser and use Print, then Save as PDF. Or open it in a text editor, copy the HTML code and paste it into the free online HTML to PDF converter.
How do I convert HTML to PDF automatically?
Use a library from your application. With the ExpertPdf HTML to PDF Converter for .NET, one method call converts a URL, an HTML file or an HTML string, so invoices, reports and tickets are created without anyone printing them.
Will links and page breaks be kept?
With the ExpertPdf converter, links stay clickable in the PDF and page breaks follow the CSS 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.

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