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

  1. Paste <h1>Report</h1><p>Text</p>.
  2. Choose A4, portrait, 15 mm.
  3. Save as PDF opens the print dialog; choose the PDF destination.

Result: The PDF follows the preview layout.

📄 HTML to PDF Converter

Free, no sign-up; your data stays in your browser.

Open the calculator →

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.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice