PDF parameters
A template’s params.json controls how the browser prints the page to PDF. All fields are optional; unset fields use the browser’s defaults. These map to the Chrome DevTools Page.printToPDF parameters.
Full example
{
"pdf": {
"landscape": false,
"printBackground": true,
"preferCSSPageSize": false,
"scale": 1.0,
"paperWidth": 8.27,
"paperHeight": 11.69,
"marginTop": 0.4,
"marginBottom": 0.4,
"marginLeft": 0.4,
"marginRight": 0.4,
"waitLifecycleEvent": "load"
}
}Fields
| Key | Type | Meaning |
|---|---|---|
landscape | bool | Landscape orientation. |
printBackground | bool | Print background graphics/colors. |
preferCSSPageSize | bool | Let a CSS @page size win over paperWidth/paperHeight. |
scale | number | Rendering scale factor. |
paperWidth | number | Paper width, inches. |
paperHeight | number | Paper height, inches. |
marginTop / marginBottom / marginLeft / marginRight | number | Margins, inches. |
waitLifecycleEvent | string | Which page event to await before printing. See Lifecycle events. |
Note: the JSON keys are lowercase (
scale, notScale). A capitalized key is ignored and the default is used.
Page size via CSS
Instead of paperWidth/paperHeight, you can size pages from CSS and set preferCSSPageSize: true:
@page { size: A4; margin: 12mm; }This is often the cleanest approach for print-specific layouts, and lets you use @page :first, named pages, and page breaks (break-after: page).
Defaults
Without params.json, the browser’s letter-size defaults apply and the renderer waits for the load event. Set only the fields you need to change.