Turn HTML Into a PDF Without Sending It to a Rendering Service
Upload an .html file or paste markup straight into the box, and the page is rendered and captured as an A4 PDF using jsPDF and html2canvas — entirely inside your browser.
About the HTML to PDF Converter
There are two ways to feed this converter. You can select an .html or .htm file, or you can ignore the file picker entirely and paste markup into the text area labelled Or paste HTML here — handy when the thing you want as a PDF is a snippet rather than a saved document. Whichever route you take, any script tags in the input are stripped before anything is rendered, so pasting markup you did not write cannot execute code in your browser.
The markup is then placed into an off-screen container 794 pixels wide, which is A4 at ninety-six dots per inch, with forty pixels of padding and black text on white. html2canvas photographs that container at double resolution, and jsPDF slices the resulting image into A4-sized pages and assembles them into a document.
Key Features
- File or paste, your choice: Accepts .html and .htm uploads, or raw markup typed or pasted into the options box — no file needs to exist on disk.
- Scripts removed before rendering: Script blocks are stripped from the input as a safety measure, so untrusted markup cannot run.
- A4 geometry from the start: Content is laid out at 794 pixels wide, the true pixel width of an A4 page, so line breaks fall where they will fall in the finished PDF.
- Double-resolution capture: The render happens at scale 2, so text edges stay crisp rather than soft when the PDF is viewed at full size or printed.
- Automatic pagination: Content taller than one page is sliced across as many A4 pages as it needs; there is no manual page-splitting to do.
- Inline CSS is honoured: Style rules written inside the markup are applied during rendering, so your layout, spacing and colours carry through.
How to Use the HTML to PDF Converter
- Either select an .html file, or paste your markup into the box beneath the file area.
- Press Convert to PDF.
- Wait through the preparing, rendering and page-building stages — a long document takes a few seconds.
- Download the PDF, which is named after your source file, or document.pdf if you pasted markup.
How It Works
The important thing to know is that the output is an image-based PDF. html2canvas rasterises the rendered markup into a canvas, and each A4 slice of that canvas is embedded as a JPEG at ninety-two percent quality. The pages look exactly like the browser rendering, but there is no text layer: you cannot select or search the text, and hyperlinks are pictures of hyperlinks rather than working ones. If a searchable PDF matters, print to PDF from your browser instead — this tool exists for fidelity to the rendered pixels, not for text retention.
Two further limits follow from the same approach. Because the capture is a straight slice of a tall image, a line of text sitting on a page boundary can be cut in half. And because the site blocks third-party requests, external stylesheets, web fonts and remotely hosted images referenced in your markup will not load — put styles in a style block and images in as data URIs if you need them to appear.
When You Need It
An online seller generates order receipts from an HTML template and needs each one as a PDF to attach to a customer email. The template contains names, addresses and order values, so running it through a hosted HTML-to-PDF API would mean routing customer data through a third party for the sake of a file format conversion.
An estate agent has a property listing laid out as HTML and wants a printable brochure for a viewing. Vendor details and internal photographs of someone's home are not things to hand to an anonymous converter, and the whole job takes seconds locally.
It is equally useful for the mundane: pasting a formatted table, a signed-off piece of copy, or an email you have already written into the box and getting back something you can archive or attach without opening a word processor.