Skip to main content

How it works

PDFBase loads your HTML into a headless Chromium browser, renders it exactly as Chrome would, and captures the result as a PDF. This means full support for:
  • CSS Grid, Flexbox, @media print
  • Web fonts (Google Fonts, custom @font-face)
  • SVG, Canvas, inline images
  • JavaScript execution (charts, dynamic content)
  • CSS page-break-before, page-break-after, page-break-inside

Basic usage

Full HTML document

For production use, send a complete HTML document with <!DOCTYPE html>, <head>, and styles:

Page breaks

Control where pages break using CSS:

Headers and footers

Headers and footers are rendered separately from the main content and appear on every page:

Special CSS classes in headers/footers

Headers and footers cannot reference styles or scripts from the main HTML body. They render in a separate context. Include all styles inline.

Web fonts

Google Fonts load automatically. For custom fonts, use @font-face with a publicly accessible URL:
Use wait_until: "networkidle" (the default) to ensure all fonts finish loading before capture. If a font takes too long, resource_timeout will skip it and fall back to the next font in the stack.

From a URL

Instead of sending HTML, point PDFBase at a live URL:
The URL is loaded in Chromium and rendered identically to how it appears in Chrome. Pass a wait_for_selector to wait for dynamic content to finish loading. Add a @media print block to adjust styling for PDF output:

Common pitfalls