mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
d89072a368
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
34 lines
9.1 KiB
Markdown
34 lines
9.1 KiB
Markdown
---
|
|
sidebar_label: PDFOptions
|
|
---
|
|
|
|
# PDFOptions interface
|
|
|
|
Valid options to configure PDF generation via [Page.pdf()](./puppeteer.page.pdf.md).
|
|
|
|
#### Signature:
|
|
|
|
```typescript
|
|
export interface PDFOptions
|
|
```
|
|
|
|
## Properties
|
|
|
|
| Property | Modifiers | Type | Description | Default |
|
|
| ------------------- | --------------------- | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
|
|
| displayHeaderFooter | <code>optional</code> | boolean | Whether to show the header and footer. | <code>false</code> |
|
|
| 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. | <code>false</code> |
|
|
| margin | <code>optional</code> | [PDFMargin](./puppeteer.pdfmargin.md) | Set the PDF margins. | <code>undefined</code> no margins are set. |
|
|
| omitBackground | <code>optional</code> | boolean | Hides default white background and allows generating pdfs with transparency. | <code>false</code> |
|
|
| 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. | <code>undefined</code>, 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. | <code>false</code> |
|
|
| scale | <code>optional</code> | number | Scales the rendering of the web page. Amount must be between <code>0.1</code> and <code>2</code>. | <code>1</code> |
|
|
| timeout | <code>optional</code> | number | Timeout in milliseconds. Pass <code>0</code> to disable timeout. | <code>30_000</code> |
|
|
| width | <code>optional</code> | string \| number | Sets the width of paper. You can pass in a number or a string with a unit. | |
|