Home › Blog & Guides PDF Conversion Guides

How to Convert HTML to PDF and PDF to HTML for Free

By ToolMaster Team · November 26, 2026 · 6 min read · PDF Conversion Guides

HTML is how the web is built, and PDF is how documents are shared, printed and archived. Converting between the two is useful for invoices, receipts, reports, newsletters and saving content you want to keep. This guide explains how to convert HTML to PDF and PDF to HTML for free, how to keep your layout intact and how to avoid the problems that make converted files look broken.

When converting HTML to PDF makes sense

Developers and small businesses often generate documents as HTML because it is easy to template: a loop fills in line items, CSS handles the branding and the same code works for every customer. A PDF, on the other hand, looks identical on every device, prints at the exact size you designed and is harder to edit by accident. Turning HTML into PDF combines both strengths. Common uses include invoices and receipts, order confirmations, certificates, reports built from dashboards, email newsletters you want to archive and documentation pages you need to send to someone offline.

How to convert HTML to PDF in three steps

  1. Paste or upload your HTML. Open the HTML to PDF converter and paste raw HTML, including any style tags, or upload a saved .html file.
  2. Check the live preview. The preview shows how fonts, colours, tables and images will render. Fix anything that looks wrong in the code before you export.
  3. Generate and download the PDF. The document is created in your browser and saved to your device. Nothing is uploaded to a server.

Because processing happens locally, you can safely convert documents that contain customer names, addresses or prices. We explain why that matters in our article on why client-side PDF processing is better.

Preparing HTML so the PDF looks right

Most conversion problems come from the source HTML rather than the converter. A few habits make a big difference:

  • Inline your critical CSS. External stylesheets behind a login or on a slow server may not load. Put the styles the document needs in a style tag in the head.
  • Use full image URLs or data URIs. Relative paths such as images/logo.png only work when the file sits next to the HTML. An absolute URL or an embedded base64 image always resolves.
  • Choose reliable fonts. Web-safe fonts such as Arial, Georgia or system fonts render consistently. If you use a custom font, make sure it loads before export.
  • Set the page size. Add an @page rule such as size A4 or size Letter with margins of around 15 to 20 mm so content does not touch the edge.
  • Avoid fixed widths wider than the page. An A4 page is roughly 794 pixels wide at 96 DPI. Wide tables should use percentage widths or smaller text.

Controlling page breaks

On screen a web page scrolls forever, but a PDF is cut into pages. Use break-inside: avoid on table rows, images and cards so they are not split in half, and break-before: page on section headings that should always start on a fresh page. For long tables, repeating the header row with a thead element helps readers on every page. Once the PDF is ready, you can still adjust it: add page numbers, merge it with other documents or compress it for email.

How to convert PDF to HTML

Going the other way is useful when you want to reuse the words in a PDF on a website, in a CMS or in an email. Open the PDF to HTML converter, choose your file and download the result. The converter extracts the text layer and basic structure such as headings and paragraphs, so you can edit and publish the content instead of retyping it.

Keep realistic expectations. A PDF stores text as positioned characters, not as flowing paragraphs, so multi-column layouts, footnotes and complex tables may need some tidying after conversion. If your PDF is a scan, it contains pictures of text rather than real text; run it through OCR first, as described in our guide to OCR for scanned PDF documents. If you only need the words, PDF to Text is often quicker, and if you need to edit a whole document, PDF to Word preserves more formatting.

HTML to PDF for invoices: a practical example

Imagine a small online shop that sends a dozen invoices a week. The owner keeps one HTML template with the logo, address block, a table for line items and a totals section styled with CSS. For each order she pastes the filled-in HTML into the converter, checks the preview and downloads a PDF named with the invoice number. The result looks identical every time, prints cleanly on A4 and can be password protected or signed before sending. Over a year that saves hours compared with formatting each invoice by hand in a word processor.

Common mistakes to avoid

  • Exporting before images have finished loading, which leaves empty boxes in the PDF.
  • Relying on JavaScript to build the content; static HTML converts far more reliably.
  • Using light grey text that looks fine on screen but prints too faint.
  • Forgetting to remove navigation menus, cookie banners and ads when converting a saved web page.
  • Uploading confidential HTML to tools that store files on their servers.

Frequently asked questions

Can I convert HTML to PDF without uploading my file?

Yes. ToolMaster renders your HTML and builds the PDF inside your browser, so the code and any customer data in it never leave your device.

Why do my CSS styles look different in the PDF?

Usually because external stylesheets, web fonts or images could not be loaded. Put critical CSS in a style tag, use web-safe or embedded fonts and use full image URLs or data URIs.

How do I stop a table or image from splitting across pages?

Add the CSS rule break-inside: avoid to the element, and use break-before: page on headings that should always start a new page.

Will PDF to HTML give me an editable web page?

It gives you HTML that keeps the text and basic structure so you can copy, edit or publish it. Complex layouts may need tidying, and scanned PDFs need OCR first because they contain images rather than text.

Is HTML to PDF good for invoices and receipts?

Yes. Building the invoice as an HTML template and converting it to PDF gives consistent, professional documents that print well and cannot be casually edited by the recipient.

What page size should I use?

Use A4 for most countries and Letter for the United States and Canada. Set it with the CSS @page rule together with sensible margins, typically 15 to 20 mm.

Try the tools mentioned in this guide

More guides