HTML to PDF Converter
Convert HTML code or files to downloadable PDF documents. Paste HTML, upload .html files, configure page size, margins, and orientation for professional PDF output.
PDF Settings
About
Converting HTML to PDF is a document-encoding problem, not a rendering problem. Browsers render HTML natively, but encoding that render into the ISO 32000 PDF specification requires constructing a binary stream with cross-reference tables, content streams, and font embedding metadata. Getting this wrong produces corrupt files that fail silently in some readers, break print workflows, or lose text selectability. This tool parses your HTML input, renders it to a pixel-accurate raster via a headless canvas pipeline, then encodes each page tile into a standards-compliant PDF with configurable page size (W × H in mm), margins, and orientation. It approximates screen rendering; CSS features like @media print rules in your source HTML are not evaluated. Complex layouts with floats, fixed positioning, or web fonts may deviate from browser output.
Formulas
The rendered HTML is rasterized at a configurable scale factor s, then sliced into page-sized tiles. Each tile height in pixels is derived from the physical page dimensions minus margins:
where Hpage is the page height in mm, mtop and mbottom are top and bottom margins in mm, 96 is the CSS reference pixel density in dpi, and 25.4 converts mm to inches. The total number of pages is:
where Hrendered is the total pixel height of the fully rendered HTML content. Each tile is drawn onto an intermediate canvas, exported as JPEG with quality factor q ∈ [0.1, 1.0], then embedded into a PDF page object stream.
Reference Data
| Page Format | Width (mm) | Height (mm) | Width (in) | Height (in) | Common Use |
|---|---|---|---|---|---|
| A3 | 297 | 420 | 11.69 | 16.54 | Posters, engineering drawings |
| A4 | 210 | 297 | 8.27 | 11.69 | Standard documents (ISO) |
| A5 | 148 | 210 | 5.83 | 8.27 | Booklets, flyers |
| Letter | 215.9 | 279.4 | 8.5 | 11 | Standard documents (US/CA) |
| Legal | 215.9 | 355.6 | 8.5 | 14 | Legal contracts (US) |
| Tabloid | 279.4 | 431.8 | 11 | 17 | Newspapers, large spreadsheets |
| Executive | 184.15 | 266.7 | 7.25 | 10.5 | Memos, executive letters |
| B4 (ISO) | 250 | 353 | 9.84 | 13.90 | Envelopes, maps |
| B5 (ISO) | 176 | 250 | 6.93 | 9.84 | Books, magazines |
| Statement | 139.7 | 215.9 | 5.5 | 8.5 | Half-letter, invoices |
| DL Envelope | 110 | 220 | 4.33 | 8.66 | Standard mailing envelopes |
| C5 Envelope | 162 | 229 | 6.38 | 9.02 | A5 sheet mailing |