How to convert HTML to PDF
- Open an .html file, or paste your HTML code into the box. The preview updates as you type.
- Choose the paper (A4 or US Letter), the orientation and the margins. Dashed lines in the preview show where pages end.
- Save it: Open print window and choose Save as PDF for the best result, or press Download PDF.
Print to PDF or download: which to use
| Feature | Print → Save as PDF | Download PDF |
|---|---|---|
| Text you can select, search and copy | Yes | No (pictures of pages) |
| Clickable links | Yes | No |
| File size | Small | Larger: each page is a picture, a few hundred KB |
| Phones | Best on a computer; phones may print the whole page or a blank one | Works everywhere |
| Page breaks | Chosen by your browser | As shown by the dashed lines |
Printing uses your browser's own engine, the same one that shows the preview, so the PDF has real text in the fonts you see. We looked at JavaScript libraries that write PDFs directly; they redraw HTML with their own, simpler layout rules and limited fonts, so they would lose more of your design than the browser does. That is why the print route is the recommended one, and the download is there for phones and quick results.
Example: an A4 page with 10 mm margins
A4 is 210 mm wide. Taking 10 mm off each side leaves 190 mm, which is 538.6 points or 718.1 CSS pixels (a CSS pixel is 1/96 inch), and the page holds 1047 pixels of height. A 900-pixel-wide email is wider than that, so it is shrunk by 718.1 ÷ 900 = 0.797, about 80%, the way a browser shrinks a page that doesn't fit when printing. Page breaks are moved up to the top of any line of text, picture or table row they would cut through.
What works in your HTML
- CSS in
<style>tags andstyleattributes, including tables, flexbox, grid and colours. Backgrounds are kept when printing. - Images and fonts embedded as data: URLs. Files on other websites or in folders aren't loaded.
- Page breaks you set with
break-before: page(or the olderpage-break-before: always). - Scripts don't run, so content that JavaScript would add won't appear. Save the finished page from your browser first.
Going the other way? Use PDF to HTML. For plain text, Text to PDF is simpler, and Markdown to HTML makes HTML you can paste here.