puppeteer/docs/api/puppeteer.page.pdf.md

55 lines
942 B
Markdown
Raw Normal View History

2022-07-05 13:41:43 +00:00
---
sidebar_label: Page.pdf
---
# Page.pdf() method
2023-03-27 09:39:40 +00:00
Generates a PDF of the page with the `print` CSS media type.
#### Signature:
2022-07-05 13:41:43 +00:00
```typescript
class Page {
2023-09-21 09:09:27 +00:00
abstract pdf(options?: PDFOptions): Promise<Buffer>;
2022-07-05 13:41:43 +00:00
}
```
## Parameters
<table><thead><tr><th>
2022-07-05 13:41:43 +00:00
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
options
</td><td>
[PDFOptions](./puppeteer.pdfoptions.md)
</td><td>
_(Optional)_ options for generating the PDF.
</td></tr>
</tbody></table>
2022-07-05 13:41:43 +00:00
**Returns:**
Promise&lt;Buffer&gt;
2023-03-27 09:39:40 +00:00
## Remarks
To generate a PDF with the `screen` media type, call [\`page.emulateMediaType('screen')\`](./puppeteer.page.emulatemediatype.md) before calling `page.pdf()`.
By default, `page.pdf()` generates a pdf with modified colors for printing. Use the [\`-webkit-print-color-adjust\`](https://developer.mozilla.org/en-US/docs/Web/CSS/-webkit-print-color-adjust) property to force rendering of exact colors.