Skip to main content

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

KeyTypeMeaning
landscapeboolLandscape orientation.
printBackgroundboolPrint background graphics/colors.
preferCSSPageSizeboolLet a CSS @page size win over paperWidth/paperHeight.
scalenumberRendering scale factor.
paperWidthnumberPaper width, inches.
paperHeightnumberPaper height, inches.
marginTop / marginBottom / marginLeft / marginRightnumberMargins, inches.
waitLifecycleEventstringWhich page event to await before printing. See Lifecycle events.

Note: the JSON keys are lowercase (scale, not Scale). 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.