← Back to Blog

2026-06-03

HTML to PDF: How the Browser Print Engine Works

Our HTML to PDF tool uses your browser's native print engine — no server, no headless Chrome. Here is exactly what that means for quality and limitations.

The Simplest Possible HTML to PDF Pipeline

Most HTML-to-PDF tools run a headless browser on a server — Puppeteer, Playwright, wkhtmltopdf. They spin up a full Chromium instance, load your HTML, and call page.pdf().

Our tool skips the server entirely. It renders your HTML in a sandboxed <iframe> in your browser tab, then calls window.print(). Your browser's built-in PDF export does the rest.

Why This Works Better Than You'd Expect

Modern browsers have excellent print engines. Chrome's print-to-PDF output is identical to what Puppeteer produces — because Puppeteer is Chrome under the hood. You get:

  • Accurate CSS rendering — flexbox, grid, custom properties, all supported
  • System fonts — fonts installed on your machine render correctly
  • @media print rules — your existing print stylesheets are respected

How to Get the Best Output

Add a <style> block with print-specific rules:

<style>
  @media print {
    body { margin: 1cm; font-family: Georgia, serif; font-size: 11pt; }
    h1 { font-size: 18pt; page-break-after: avoid; }
    table { page-break-inside: avoid; }
    a { color: black; text-decoration: none; }
  }
</style>

Key rules to include:

  • Set explicit margin on body to control page margins
  • Use page-break-inside: avoid on tables and code blocks
  • Convert colors to black if the output will be printed physically

Limitations

  • External resources — images from external URLs load only if those servers allow cross-origin requests. Embed images as base64 to guarantee rendering.
  • JavaScript — the iframe is sandboxed, so JS-rendered content won't appear. Pre-render dynamic content before pasting.
  • Page size — determined by your browser's print settings. Set it to A4 or Letter in the print dialog before saving.

Privacy

Your HTML never leaves your browser. The iframe renders locally, and window.print() triggers your OS print system directly. Nothing is uploaded.