How to Convert HTML to PDF: Paper and Margins
Last updated: · 2 min read
Invoices, CVs and reports written in HTML can become PDF without uploading them anywhere; the browser's print feature writes PDF. The tool shows the HTML in a safe preview, sets paper, orientation and margin and opens the print dialog.
Formula
@page { size: A4 portrait; margin: 15mm }
.break { break-after: page }Paper is set with the CSS @page rule; scripts are not run and the document never leaves your device.
What the inputs mean
- HTML
- The code to preview, with styles.
- Paper
- A4, A5, Letter and others.
- Orientation
- Portrait or landscape.
- Margin
- In millimetres.
Worked example: A simple document
- Paste <h1>Report</h1><p>Text</p>.
- Choose A4, portrait, 15 mm.
- Save as PDF opens the print dialog; choose the PDF destination.
Result: The PDF follows the preview layout.
How to read the result
Turn on background graphics in the dialog to keep colours. Remote fonts and images appear only if reachable.
Common mistakes
- Leaving background graphics off.
- Splitting a long table without page-break rules.
- Printing before fonts load.
Frequently asked questions
Is my code uploaded?
No, everything happens in your browser.
Why not download directly?
Browsers save PDF through printing, which keeps the layout.
Does JavaScript run?
No, scripts are disabled in the preview.
The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.