Turn an HTML file into a PDF

or drop one here
Choose an HTML file first.

Convert an HTML file into a PDF without uploading it. This tab strips every script, frame and remote request, mounts the markup in a sandboxed frame at the PDF text width, and reads the settled layout back: headings, lists, tables with spans, block quotes, images, links and footnotes. Every character is drawn as selectable text, and the finished PDF is reopened and 98% of its text must come back.

How to turn an HTML file into a PDF

  1. Choose an HTML file

    Press Choose an HTML file, or drop one on the page. The file is opened in this browser tab.

  2. The tool strips what would load or run

    Scripts, frames, stylesheet links, trackers and remote images are removed before the markup is shown anything. What is left cannot fetch and cannot execute.

  3. It measures the page at the PDF text width

    The markup is mounted in a sandboxed frame exactly as wide as the PDF text column, and the settled layout is read back: boxes, borders, indents, list markers, table columns and line heights.

  4. Check and download

    The new PDF is reopened with a separate reader and its text compared with the text the layout used. A failed check does not produce a download.

What the conversion can preserve

An HTML file describes content plus the rules for laying it out, and those rules only produce a layout once a browser runs them at some width. A PDF describes finished pages. This tool does not guess at the difference: it mounts the markup in a frame exactly as wide as the PDF's text column and reads the layout the browser settles on. Column widths, indents, list markers, table geometry, borders, background shading and line heights are the browser's own numbers, not an approximation of them.

The frame is the part that has to be safe. It is created with no script permission at all, so nothing in the file runs, and the markup is stripped before it is ever mounted. Scripts, frames, objects, embeds, media elements, stylesheet links, a base tag and a meta refresh are removed. Event handler attributes go, javascript: URLs go, and CSS @import and remote url() references are rewritten out, so no stylesheet, font, image or tracker is fetched while your file is open. Every removal is counted by kind and the count appears on the receipt, so a page that lost its external stylesheet says so instead of quietly converting to something plainer.

Notes become real footnotes rather than a list at the end. Three signals are read in order: an anchor marked role="doc-noteref", an anchor marked epub:type="noteref", and a superscript link whose text is a marker such as 1, [2], iv or a dagger. The target must sit after the reference and be short enough to be a note body. When that holds, the reference is written as a footnote reference, the body is set at the foot of the page that cites it, and the original note list is consumed rather than printed a second time. Links are kept both ways: an internal jump is rewritten to the block that claimed its target, and an http, https, mailto or tel link is written as a live PDF link. A fragment nothing claims is counted as dropped.

Images stored in the file are embedded. A PNG or JPEG passes through untouched, since re-encoding it would cost quality for nothing. Any other format is decoded and re-encoded through a canvas, as a JPEG when it is opaque and a PNG when it is not, and an inline SVG is rasterised at three times its box. A picture the file only links to is counted as dropped, because fetching it is the thing this tool will not do.

What does not carry is anything that needs a viewport rather than a page. Side-by-side floats and multi-column CSS are written one column down the page in document order, with the indents each block's own box gives it. A fixed or sticky element lands where the settled layout put it. A page whose appearance depends on a stylesheet held on another site converts as the markup without it.

The check is the reason there is a download. The PDF this tool wrote is reopened with pdf.js, a reader that shares no code with the writer, and its non-space characters are counted against the characters the layout consumed. Below 98% nothing is offered.

How to convert HTML to PDF covers this tool end to end, and Save a webpage as HTML covers getting a live page into the file this tool takes.

Questions

Does HTML to PDF upload my file?
No. The file is read, stripped, measured, drawn, reopened and checked in this browser tab. The bytes never leave it.
Does converting fetch anything from the web?
No. Every script, frame, stylesheet link and remote image is removed before the markup is mounted, and CSS @import and remote url() references are rewritten out. The receipt counts what was removed. A page that only looks right because it pulls a stylesheet from a CDN converts as the unstyled markup, because that stylesheet is exactly what the tool refuses to fetch.
What carries over from the HTML?
Headings, paragraphs, bold, italic, sizes, colour, background shading, alignment, indents, line height, ordered and unordered lists with their markers, nested lists, tables with colspan and rowspan, cell padding, cell borders and shading, block quotes, preformatted blocks, horizontal rules, inline images, inline SVG, links, and footnotes with their markers and bodies.
How does it find footnotes?
By three signals, in order. An anchor marked role="doc-noteref", an anchor marked epub:type="noteref", or a superscript link whose text is a note marker such as 1, [2], iv or a dagger. The target has to sit after the reference in the document and be short enough to be a note body rather than a section. When a match is found the marker becomes a real PDF footnote reference, the body is set at the bottom of the page it is cited on, and the original list of notes at the end of the file is not printed twice.
What about pages built by JavaScript?
The markup is shown with its scripts already gone, so what converts is what the file already says. A page whose content is written by a script at load time has no content in the file, and the tool converts what is there rather than running code from a file you opened.
Are images kept?
Images stored in the file as data URIs are kept. A PNG or JPEG is embedded untouched. Any other format is re-encoded through a canvas, and an inline SVG is drawn at three times its box so it stays sharp. An image the file only links to cannot be fetched, so it is counted as dropped rather than silently missing.
Will the layout match the browser?
The text and the block structure will. Column widths, indents, list markers, table geometry and line heights are read from a real layout at the PDF text width, so they are the browser’s own numbers. What does not carry is anything that depends on a viewport rather than a page: side-by-side floats and multi-column CSS are written one column down the page in document order, and a fixed or sticky element is placed where the settled layout put it.
Does the PDF keep selectable text, and what is counted?
Every character is drawn as text with its own font, never as a picture of a page. The tool then reopens the PDF it wrote with pdf.js and counts the non-space characters it finds. At least 98% of the text the layout used must come back, or no download is offered.

The other pdfpix tools

All 37 of them run in a browser tab like this one. Each reads its own output back and checks it before offering the download, and none of them needs an account.

Where to go next