The problem
PDF rendering depends on external assets: fonts, images, stylesheets. Any of these can fail, be slow, or load in the wrong order — causing blank areas, wrong fonts, or broken layouts. PDFBase gives you explicit control over asset loading behavior.wait_until
Controls when PDFBase considers the page “ready” to capture:
Default:
networkidle (safest, slightly slower).
wait_for_selector
Wait for a specific CSS selector to appear before capturing. Useful when JavaScript dynamically creates content:wait_for_timeout
Add a fixed delay afterwait_until fires. Use as a last resort when there’s no reliable signal:
resource_timeout
Max time to wait for each individual resource. Resources that exceed this are skipped:skip_failed_resources
Controls behavior when a resource fails to load:true(default): Continue rendering. The PDF will have missing images or fallback fonts, but it will generate.false: Fail the entire request. Returns an error listing the failed resources.
false for templates where every asset is critical (e.g., a branded certificate where the logo must be present).
Font loading
Google Fonts
Just link them in your HTML. They load automatically:Bundled fonts
PDFBase includes 6 high-quality font families that don’t require any network loading:- Inter — Clean sans-serif (body text)
- JetBrains Mono — Monospace (code)
- Merriweather — Serif (documents)
- Noto Sans — Wide Unicode coverage (internationalization)
- Noto Sans CJK — Chinese, Japanese, Korean
- Noto Sans Arabic — Arabic script
Fallback behavior
When a custom font fails to load (network error, timeout, 404), PDFBase automatically falls back to the closest bundled font based on the CSSfont-family stack:
The fallback is CSS-standard: PDFBase follows your
font-family stack, substituting the first available bundled font that matches the generic family. If no generic family is specified, Inter is the final fallback.
To see which font was actually used, enable debug: true. The console output will log any font substitution:
Custom fonts
Host your font files on a CDN and use@font-face:
Image loading
Inline images (base64)
For critical images that must always appear, embed them as base64:Remote images
For non-critical images, use URLs. Pair withresource_timeout and skip_failed_resources: