Keep background colours and images in a PDF
Print background colours and images. Off by default in browsers; on by default here.
| Field | options.printBackground |
| Type | true | false |
| Default | true |
What it is for
Whether backgrounds are painted. Chromium omits them by default — the browser print dialog does the same thing, on the theory that you do not want to spend ink on them.
The trap
Almost every invoice, report and certificate wants this ON. A design with a coloured header bar that renders as plain white is this option, nine times in ten.
Example
curl -X POST https://api.pdfcraft.dev/v1/render \
-H "Authorization: Bearer $PDFCRAFT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<h1>hello</h1>",
"options": {
"printBackground": true
}
}' \
--output out.pdfEvery option
format— Paper size. Ignored if the page CSS declares its own @page size.landscape— Rotate the paper to landscape orientation.margin— Page margins. Any side may be omitted; omitted sides default to 0.scale— Rendering scale factor.printBackground— Print background colours and images. Off by default in browsers; on by default here.pageRanges— Subset of pages to keep, e.g. "1-5" or "1,4,7-9". Empty means all pages.headerHtml— HTML for the running header. Supports Chromium print classes: date, title, url, pageNumber, totalPages. Needs a top margin to be visible.footerHtml— HTML for the running footer. Same classes as headerHtml; needs a bottom margin.waitFor— Conditions to satisfy before the PDF is taken. All of them apply, in order.emulateMedia— Which CSS media type the page sees.timeoutMs— Hard ceiling on the whole render. Exceeding it returns 408 render_timeout.
Try any of these in the playground without writing a line of code, or read the full reference.