puppeteer/docs/api/puppeteer.pdfoptions.md

34 lines
9.1 KiB
Markdown
Raw Normal View History

2022-07-05 13:41:43 +00:00
---
sidebar_label: PDFOptions
---
# PDFOptions interface
Valid options to configure PDF generation via [Page.pdf()](./puppeteer.page.pdf.md).
#### Signature:
2022-07-05 13:41:43 +00:00
```typescript
export interface PDFOptions
```
## Properties
| Property | Modifiers | Type | Description | Default |
| ------------------- | --------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| displayHeaderFooter | <code>optional</code> | boolean | Whether to show the header and footer. | false |
| footerTemplate | <code>optional</code> | string | HTML template for the print footer. Has the same constraints and support for special classes as [PDFOptions.headerTemplate](./puppeteer.pdfoptions.md). | |
| format | <code>optional</code> | [PaperFormat](./puppeteer.paperformat.md) | | <code>letter</code>. |
| headerTemplate | <code>optional</code> | string | <p>HTML template for the print header. Should be valid HTML with the following classes used to inject values into them:</p><p>- <code>date</code> formatted print date</p><p>- <code>title</code> document title</p><p>- <code>url</code> document location</p><p>- <code>pageNumber</code> current page number</p><p>- <code>totalPages</code> total pages in the document</p> | |
| height | <code>optional</code> | string \| number | Sets the height of paper. You can pass in a number or a string with a unit. | |
| landscape | <code>optional</code> | boolean | Whether to print in landscape orientation. | = false |
| margin | <code>optional</code> | [PDFMargin](./puppeteer.pdfmargin.md) | Set the PDF margins. | no margins are set. |
| omitBackground | <code>optional</code> | boolean | Hides default white background and allows generating pdfs with transparency. | false |
| pageRanges | <code>optional</code> | string | Paper ranges to print, e.g. <code>1-5, 8, 11-13</code>. | The empty string, which means all pages are printed. |
| path | <code>optional</code> | string | The path to save the file to. | the empty string, which means the PDF will not be written to disk. |
| preferCSSPageSize | <code>optional</code> | boolean | Give any CSS <code>@page</code> size declared in the page priority over what is declared in the <code>width</code> or <code>height</code> or <code>format</code> option. | <code>false</code>, which will scale the content to fit the paper size. |
| printBackground | <code>optional</code> | boolean | Set to <code>true</code> to print background graphics. | false |
| scale | <code>optional</code> | number | Scales the rendering of the web page. Amount must be between <code>0.1</code> and <code>2</code>. | 1 |
| timeout | <code>optional</code> | number | Timeout in milliseconds. Pass <code>0</code> to disable timeout. | 30000 |
| width | <code>optional</code> | string \| number | Sets the width of paper. You can pass in a number or a string with a unit. | |