Advanced HTML to PDF Maker

Write a document in HTML and CSS, set the page size, orientation, margins and a header or footer with page numbers, watch a scaled live preview, and save a real PDF with selectable text through your browser’s print engine.

Tool Media & Files Updated Oct 16, 2026
How to Use
  1. Pick a preset such as A4 portrait, 10 mm margins or Letter invoice to load a document, or write your own HTML and CSS in the two boxes.
  2. Set the page size, orientation and margin in millimetres. The preview is redrawn to scale and the readouts show the page and content area in millimetres and points.
  3. Type a header or footer; {page} and {total} become the page number and page count, as in Page {page} of {total}.
  4. Press Save as PDF, choose “Save as PDF” as the printer, and untick the browser’s own headers and footers.
  5. Drop the saved PDF on Check a saved PDF to confirm its page size and page count match the setup.
Document & Page Setup
mm, 0–100
{page} {total}
{page} {total}
Presets
Live Preview
First page, to scale, with the margins. The header and footer appear only in the printed PDF.
Page
—
Content Area
—
In Points
—
Pages (estimate)
—

Worked Example

A4 portrait with 20 mm margins. The page is 210 × 297 mm, which is 210 × 72 ÷ 25.4 = 595.28 by 841.89 points in the PDF. Taking 20 mm off each side leaves a content area of 210 − 40 = 170 mm by 297 − 40 = 257 mm. CSS counts 96 px to the inch, so that area is 170 × 96 ÷ 25.4 = 642.5 px wide and 971.3 px tall: the width your HTML actually has to fit into.

US Letter landscape with 1-inch margins. Letter is 8.5 × 11 in (215.9 × 279.4 mm); turned landscape it is 11 × 8.5 in, or 792 × 612 pt. One inch off each side leaves 9 × 6.5 in, which is 228.6 × 165.1 mm and 864 × 624 CSS px.

The common mistake: designing for a screen width. A table built 1000 px wide fits a laptop window but not the 642.5 px content area of A4 with 20 mm margins, so it runs off the right edge or the browser shrinks the whole page to fit. Give wide elements width: 100%, or size them in millimetres, and let the preview, which is drawn at the real page width, show the result before you print.

Show Work

Choose a page size or a preset to see the page and content area worked out, and the CSS sent to the printer.

Formulas

Points
pt = mm × 72 ÷ 25.4
1 pt = 1/72 in, the PDF unit
CSS pixels
px = mm × 96 ÷ 25.4
CSS: 1 in = 96 px = 72 pt
Content area
W − 2m by H − 2m
m = margin on every side
Page rule
@page { size: W H; margin: m }
written in millimetres for every size
Page numbers
{page} → counter(page), {total} → counter(pages)
inside @top-center / @bottom-center
Page estimate
n ≈ ⌈content height ÷ area height⌉ + forced breaks
the print dialog shows the exact count

Printing the Web: CSS for Paper

CSS was written for screens, so printing needs extra rules from the CSS Paged Media specification. The @page rule sets the sheet size and its margins; break-before, break-after and break-inside control where pages end; and sixteen named margin boxes such as @top-center and @bottom-center can hold running headers and footers, with the page and pages counters for “Page 2 of 5”. Chrome and Firefox support @page for size and margins, and Chrome added the margin boxes in version 131, announced in October 2024.

Lengths line up exactly because CSS fixes its units to the inch: 1 in = 2.54 cm = 96 px, and 1 pt = 1/72 in. The PDF format uses the same 1/72-inch unit for page sizes, so 210 mm in CSS becomes 595.28 points in the saved file. A browser’s Save as PDF keeps text as text, so the result can be searched, copied and read aloud, unlike a PDF made from a screenshot.

About This Tool

This tool turns HTML and CSS into a printable document with an exact page size, orientation and margins, a header and footer with page numbers, a preview drawn to the real page width, and a page-count estimate. After you save, the PDF can be dropped back in to check its page size and count. Page settings can go in the page address, for example ?size=Letter&margin=25.4.

The PDF is written by your browser’s print engine, and the check reads it with the site’s PDF engine, all on your device. The document is kept only in this browser’s storage, and scripts are blocked in both the preview and the printed copy.

Related tools: PDF Info, Image to PDF, and PDF Workbench.

Frequently Asked Questions

Why does it use the browser’s print engine?

Because the browser already lays out HTML and CSS better than any add-on library, and its Save as PDF writes real text you can select and search, working links and sharp vector graphics, not a picture of the page. There is no large PDF library to download, and your document never leaves the browser. The cost is one extra click in the print dialog.

How do I add page numbers?

Type them into the header or footer: {page} becomes the current page and {total} the number of pages, so Page {page} of {total} prints “Page 2 of 5”. They are printed in the page margin with CSS margin boxes (@top-center and @bottom-center), which Chrome supports from version 131 (October 2024), and Edge, built on the same engine, too. A browser without margin-box support prints the page without them, so keep a margin of at least 10 mm for them to sit in.

How do I force or prevent a page break?

Content flows onto new pages by itself. To start a new page before an element, give it style="break-before: page" (the older page-break-before: always also works). To keep a table row, figure or heading with its text on one page, use break-inside: avoid. The Multi-page report preset shows both.

Why does my PDF have a date and a web address at the top?

Those are the browser’s own headers and footers, added by the print dialog, not by this tool. Untick “Headers and footers” in the dialog’s More settings and they disappear; your own header and footer from this page stay. If the page size in the saved file is wrong, check the dialog’s paper size too, then drop the file on Check a saved PDF.

Is my document saved or uploaded?

It is never uploaded. Your HTML, CSS and page setup are kept in this browser’s local storage so a reload does not lose them, and nowhere else. The preview runs with scripts switched off, and the copy sent to print carries a policy that blocks scripts, so HTML pasted from elsewhere cannot run code on this site.

How do I use the Advanced HTML to PDF Maker?

Simply type your numbers and read the result, which refreshes the instant you change something. There is nothing to submit and nothing to wait for.

Does it cost anything or need an account?

No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.

Is anything I type uploaded?

No. The tool works entirely on your device, so the values you enter never leave your browser.

Common Use Cases

An invoice on US Letter

Letter with 0.75 in (19.05 mm) margins leaves a 7 × 9.5 in content area for the line items and the total.

A one-page résumé

A4 with 15 mm margins gives a 180 × 267 mm area; Check a saved PDF confirms it stayed on 1 page.

An A5 flyer

A5 portrait with 10 mm margins leaves 128 × 190 mm for a poster that prints two to an A4 sheet.

A numbered report

A multi-page report with a Page {page} of {total} footer and a new page before each chapter.

Last updated: