Skip to main content
Version: Next

PDFOptions interface

Valid options to configure PDF generation via Page.pdf().

Signature:

export interface PDFOptions

Properties

PropertyModifiersTypeDescriptionDefault
displayHeaderFooteroptionalbooleanWhether to show the header and footer.false
footerTemplateoptionalstringHTML template for the print footer. Has the same constraints and support for special classes as PDFOptions.headerTemplate.
formatoptionalPaperFormatletter.
headerTemplateoptionalstring

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

- date formatted print date

- title document title

- url document location

- pageNumber current page number

- totalPages total pages in the document

heightoptionalstring | numberSets the height of paper. You can pass in a number or a string with a unit.
landscapeoptionalbooleanWhether to print in landscape orientation.false
marginoptionalPDFMarginSet the PDF margins.undefined no margins are set.
omitBackgroundoptionalbooleanHides default white background and allows generating pdfs with transparency.false
pageRangesoptionalstringPaper ranges to print, e.g. 1-5, 8, 11-13.The empty string, which means all pages are printed.
pathoptionalstringThe path to save the file to.undefined, which means the PDF will not be written to disk.
preferCSSPageSizeoptionalbooleanGive any CSS @page size declared in the page priority over what is declared in the width or height or format option.false, which will scale the content to fit the paper size.
printBackgroundoptionalbooleanSet to true to print background graphics.false
scaleoptionalnumberScales the rendering of the web page. Amount must be between 0.1 and 2.1
taggedoptionalbooleanGenerate tagged (accessible) PDF.false
timeoutoptionalnumberTimeout in milliseconds. Pass 0 to disable timeout.30_000
widthoptionalstring | numberSets the width of paper. You can pass in a number or a string with a unit.