Input options for customizing PDF generation via the ‘pdf’ query on the Page type.

Definition

input PDFOptions {
  displayHeaderFooter: Boolean
  footerTemplate: String
  format: PaperFormat
  headerTemplate: String
  height: String
  landscape: Boolean
  margin: PDFMarginOptions
  omitBackground: Boolean
  pageRanges: String
  preferCSSPageSize: Boolean
  printBackground: Boolean
  scale: Float
  timeout: Int
  width: String
}

Fields

displayHeaderFooter: Boolean

Whether to display header and footer. Defaults to false. If true, headerTemplate and footerTemplate can be used to customize them.

footerTemplate: String

HTML template for the print footer. Should be valid HTML markup with the following classes used to inject printing values into them:

  • date formatted print date
  • title document title
  • url document location
  • pageNumber current page number
  • totalPages total pages in the document Example: <div style='font-size:10px; width:100%; text-align:center;'><span class='pageNumber'></span>/<span class='totalPages'></span></div>

format: PaperFormat

Paper format for the PDF. See PaperFormat enum (e.g., A4, LETTER). If set, overrides width and height. Defaults to LETTER if not specified.

headerTemplate: String

HTML template for the print header. Same format as footerTemplate. Example: <div style='font-size:10px; color:grey; margin-left:10px;'><span class='title'></span></div>

height: String

Height of the paper. Must be a string with units (e.g., "11in", "29.7cm"). Used if ‘format’ is not set.

landscape: Boolean

Whether to print in landscape orientation. Defaults to false (portrait).

margin: PDFMarginOptions

Margin options for the PDF. See PDFMarginOptions. If not specified, default margins apply (usually around 1cm or 0.4in).

omitBackground: Boolean

Whether to omit the background graphics from the PDF. Defaults to false (backgrounds are included).

pageRanges: String

Paper ranges to print, e.g., "1-5, 8, 11-13". Defaults to all pages.

preferCSSPageSize: Boolean

Whether to prefer page size defined in CSS (@page) over options width/height or format. Defaults to false.

printBackground: Boolean

Whether to print background graphics (images and colors). Defaults to false.

scale: Float

Scale of the webpage rendering. Defaults to 1 (100%). Values less than 1 shrink, greater than 1 enlarge.

timeout: Int

Timeout in milliseconds for the PDF generation. Defaults to a global setting (e.g., 30000ms).

width: String

Width of the paper. Must be a string with units (e.g., "8.5in", "21cm"). Used if ‘format’ is not set.