Slate PDF

Converting

How to Convert HTML to PDF (With the Design Intact)

How to convert HTML to PDF with your CSS design intact: paste or upload markup, preview it, choose exact design or selectable text, and download it free.

HM

Hamza M.

PDF Workflow Editor

Updated October 13, 20264 min readReviewed October 13, 2026

Learning how to convert HTML to PDF comes down to one rule: the design has to be rendered first, then captured. A converter that reads your markup as text and prints it produces something technically correct and visually useless.

How to convert HTML to PDF

To convert HTML to PDF, render the markup in a browser engine and capture the result. In Slate PDF's HTML to PDF tool you paste code or upload an .html file, check the live preview, choose Exact design or Selectable text, and download an A4 PDF — all inside your browser, with nothing uploaded.

  1. 1Open the HTML to PDF tool and paste your markup into the HTML code tab, or upload an .html file.
  2. 2Check the Design preview — that rendered view is what the PDF will contain.
  3. 3Choose the PDF output: Exact design or Selectable text.
  4. 4Convert. The PDF downloads and its file size is shown.

Exact design or selectable text?

Exact designSelectable text
How it worksThe browser renders the page with full CSS, then the result is captured and cut into A4 pagesThe content is re-typeset as real PDF text on A4 pages
Looks like the previewYesSimplified — headings, paragraphs, lists, tables and embedded images
Text can be selected and searchedNo — each page is an imageYes
Best forInvoices, certificates, designed reportsArticles, documentation, anything that must be searchable

An Exact design PDF is a picture of your page. If it needs to be searchable later, run OCR over it, or produce a second copy in Selectable text mode.

What does not survive

FeatureIn the PDF
CSS layout, colours, typographyRendered as designed in Exact design mode
Images referenced by URLIncluded only if the image host allows cross-origin loading; data URIs always work
Web fontsApplied if they load in time — embed them or fall back to system fonts
JavaScriptNot run — scripts are blocked, so content they would generate is missing
Hover and focus statesNot applicable — a page has no cursor
Video and interactive embedsBlank space at best

Page breaks: where the cuts fall

In Exact design mode the page is laid out about 730 pixels wide — the printable width of A4 — and the result is sliced into A4-height pieces. The slices fall at fixed intervals, so CSS such as break-inside: avoid and break-before: page is not honoured, and a table row or a line of text can be cut across two pages.

  • Design for the 730-pixel width; fixed-width layouts wider than that can be clipped at the right edge.
  • Use Selectable text mode for long flowing documents — it moves whole lines to the next page rather than cutting them.
  • If exact page breaks matter, open the HTML file in your browser and use Print → Save as PDF, which does honour break rules and @media print styles.
  • Check the bottom edge of every page in the download, not just the first.

Troubleshooting

  • Unstyled output: an external stylesheet did not load. Inline it in a style tag.
  • Missing images: the host blocks cross-origin requests. Embed them as data URIs.
  • Empty sections: the content was built by JavaScript, which does not run. Paste the rendered HTML instead — copy the element's outer HTML from your browser's inspector.
  • Question marks instead of characters in Selectable text mode: Chinese, Arabic, Hindi and similar scripts are not supported there. Use Exact design.
  • "Timed out rendering the HTML": the page took more than 20 seconds to load its assets. Remove or inline the slow ones.

Common uses

Invoices, certificates, reports and tickets are all HTML-to-PDF jobs: you build a template, fill it with data, and render. Doing the layout in HTML and CSS means the design lives in a language you already know rather than in a PDF drawing API. For someone else's page that is already online, the route is different — see saving a web page as a PDF.

Do it now

HTML to PDF

Convert HTML code or .html files to PDF. It runs in this browser tab — your file is not uploaded anywhere.

Open HTML to PDF

Frequently asked questions

Why does my PDF look unstyled?+

The CSS did not reach the renderer. External stylesheets can fail to load, so inline the styles in a style tag and convert again.

Can I convert a live website URL to PDF?+

This tool converts markup you provide. For a live page, use your browser's own Print to PDF, which renders the page exactly as you are seeing it.

How do I stop a table splitting across pages?+

Exact design mode cuts at fixed page heights and ignores CSS break rules. For controlled breaks, print the HTML from your browser to PDF, or use Selectable text mode.

Can I select the text in the PDF?+

Only in Selectable text mode. Exact design mode captures each page as an image, so the text looks right but cannot be selected or searched.

Do web fonts work?+

If they load before capture. Safest is a system font stack, or the font embedded as a data URI in your CSS.

Keep reading

HM

Hamza M. · PDF Workflow Editor

Hamza has spent a decade working with print and digital documents — from prepress production to everyday PDF cleanup — and now writes practical, tested guides for Slate PDF.

Read more about how this site is run