Add print CSS¶
This guide shows you how to add custom CSS to the generated PDF.
Create a stylesheet¶
Create print.css:
Convert with the stylesheet¶
Run:
The custom CSS is appended after the built-in print styles.
Remote url() and @import resources are blocked by default. If a trusted stylesheet deliberately needs HTTP(S) assets, add --allow-remote-assets; this permits the document to contact private and local network services too. Prefer local assets with --allow-local-files when possible.
You should see:
Open the PDF and check that the heading uses the custom color.
Tip
Use print-focused CSS here. Browser-only interactive styles will not affect the generated PDF.
For layout problems, keep the generated HTML with Debug rendering.