Skip to content

PDF route body parameters

To render a PDF, set pdf under the page property:

pdf properties for PDF routes

These properties follow Puppeteer's PDFOptions type.

Property nameTypeDescription
scalenumberScales the rendering of the page. The value must be between 0.1 and 2. optional
displayHeaderFooterbooleanWhether to show the header and footer. optional
headerTemplatestringHTML template for the print header. See the valid HTML pattern below. optional
footerTemplatestringHTML template for the print footer. Has the same constraints and support for special classes as PDFOptions.headerTemplate. optional
printBackgroundbooleanSet to true to print background graphics. optional
landscapebooleanWhether to print in landscape orientation. optional
pageRangesstringPaper ranges to print, e.g. 1-5, 8, 11-13. optional
formatPaperFormatAll the valid paper format types when printing a PDF. See all formats. optional
widthstring, numberSets the width of paper. You can pass in a number or a string with a unit. optional
heightstring, numberSets the height of paper. You can pass in a number or a string with a unit. optional
marginMarginSets the margin of every page. See the expected properties here optional
preferCSSPageSizebooleanGives any CSS @page size declared in the page priority over the width, height, or format option. optional
omitBackgroundbooleanHides the default white background and allows generating PDFs with transparency. optional

Valid HTML pattern for headerTemplate and footerTemplate

It must be valid HTML (base64-encoded) and can include the following classes, which will be replaced with runtime values:

  • date: formatted print date
  • title: document title
  • url: document location
  • pageNumber: current page number
  • totalPages: total number of pages in the document

Paper formats

Format nameSize in inchesSize in cmSize in feet
Letter8.5in x 11in21.6cm x 27.9cm0.666ft x 0.917ft
Legal8.5in x 14in21.6cm x 35.6cm0.666ft x 1.167ft
Tabloid11in x 17in27.9cm x 43.2cm0.917ft x 1.417ft
Ledger17in x 11in43.2cm x 27.9cm1.417ft x 0.917ft
A033.1in x 46.8in84cm x 118.9cm2.757ft x 3.898ft
A123.4in x 33.1in59.4cm x 84cm1.948ft x 2.757ft
A216.54in x 23.4in42cm x 59.4cm1.377ft x 1.948ft
A311.7in x 16.54in29.7cm x 42cm0.974ft x 1.377ft
A48.27in x 11.7in21cm x 29.7cm0.689ft x 0.974ft
A55.83in x 8.27in14.8cm x 21cm0.485ft x 0.689ft
A64.13in x 5.83in10.5cm x 14.8cm0.344ft x 0.485ft

Margin

Property nameTypeDescription
topstring, numberTop margin optional
rightstring, numberRight margin optional
leftstring, numberLeft margin optional
bottomstring, numberBottom margin optional

All rights reserved