Overview
This node uses Puppeteer to interact with web pages and generate PDFs from them. It is useful for automating the creation of PDF documents from web content, such as generating reports, invoices, or capturing web pages for archival. The node supports detailed PDF customization including page size, margins, scaling, header/footer templates, and background options.
Use Case Examples
- Generate a PDF report from a dynamic web page URL with custom margins and header/footer.
- Convert a web page to PDF with specific page ranges and landscape orientation.
- Create a transparent background PDF from a web page for overlay purposes.
Properties
| Name | Meaning |
|---|---|
| URL | The web page URL to generate the PDF from. |
| Property Name | The name of the binary property to store the generated PDF data. |
| Page Ranges | Specifies which pages to print in the PDF, e.g., 1-5, 8, 11-13. |
| Scale | Scales the rendering of the web page between 0.1 and 2. |
| Prefer CSS Page Size | Whether to prioritize CSS @page size over width, height, or format options. |
| Format | Paper format type for the PDF when CSS page size is not preferred. |
| Height | Height of the paper, can be a number or string with unit, used if CSS page size is not preferred. |
| Width | Width of the paper, can be a number or string with unit, used if CSS page size is not preferred. |
| Landscape | Whether the PDF should be in landscape orientation. |
| Margin | Margins for the PDF pages (top, bottom, left, right). |
| Display Header/Footer | Whether to show header and footer in the PDF. |
| Header Template | HTML template for the PDF header, supports placeholders for date, title, url, pageNumber, totalPages. |
| Footer Template | HTML template for the PDF footer, supports placeholders for date, title, url, pageNumber, totalPages. |
| Transparent Background | Whether to generate the PDF with a transparent background instead of white. |
| Background Graphics | Whether to include background graphics in the PDF. |
| Query Parameters | Query parameters to append to the URL when loading the page. |
| Options | Additional Puppeteer options such as batch size, browser WebSocket endpoint, device emulation, executable path, headers, file name, launch arguments, timeout, waitUntil event, page caching, headless mode, stealth mode, proxy server, and container arguments. |
Output
Binary
Contains the generated PDF file data stored in the specified binary property.
JSON
headers- HTTP response headers from the page request.statusCode- HTTP status code of the page request.url- The URL of the web page that was converted to PDF.
Dependencies
- Puppeteer library for browser automation
- puppeteer-extra and puppeteer-extra-plugin-stealth for stealth mode
Troubleshooting
- Common issues include invalid URLs causing navigation failures, which result in errors with HTTP status codes. Verify the URL format and accessibility.
- Browser launch failures may occur due to incorrect executable paths or missing dependencies; ensure Puppeteer is properly installed and configured.
- Timeout errors can happen if the page takes too long to load; adjust the timeout option accordingly.
- Errors in custom header/footer HTML templates can cause PDF generation to fail; validate the HTML syntax and placeholders.
Links
- Puppeteer Documentation - Official Puppeteer documentation for browser automation and PDF generation.