Overview
This node uses Puppeteer to generate a PDF from a specified web page URL. It is useful for automating the creation of PDFs from web content, such as generating reports, invoices, or saving web pages for offline viewing. The node supports various PDF customization options like page size, margins, orientation, scaling, headers/footers, background graphics, and page ranges.
Use Case Examples
- Generate a PDF of a product page for archiving.
- Create a PDF report from a dashboard URL with custom headers and footers.
- Save a multi-page article as a PDF with specific page ranges and landscape orientation.
Properties
| Name | Meaning |
|---|---|
| URL | The web page URL to generate the PDF from. |
| Property Name | The name of the binary property to store the PDF data. |
| Page Ranges | Specific page ranges to include in the PDF, e.g., 1-5, 8, 11-13. |
| Scale | Scale factor for rendering the web page, between 0.1 and 2. |
| Prefer CSS Page Size | Whether to prioritize CSS @page size declarations over width, height, or format options. |
| Format | Paper format type for the PDF, e.g., Letter, A4. |
| Height | Height of the paper, can be a number or string with unit. |
| Width | Width of the paper, can be a number or string with unit. |
| Landscape | Whether to use landscape orientation for the PDF. |
| Margin | Margins for the PDF (top, bottom, left, right). |
| Display Header/Footer | Whether to show header and footer in the PDF. |
| Header Template | HTML template for the print header with placeholders for date, title, url, pageNumber, totalPages. |
| Footer Template | HTML template for the print footer with placeholders for date, title, url, pageNumber, totalPages. |
| Transparent Background | Whether to generate the PDF with a transparent background. |
| 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, protocol, device emulation, executable path, headers, file name, launch arguments, timeouts, wait conditions, caching, headless mode, stealth mode, human typing mode, proxy server, download capture, and container arguments. |
Output
Binary
Contains the generated PDF file data stored under the specified binary property name.
JSON
headers- HTTP response headers from the page request.statusCode- HTTP status code of the page request.url- The URL of the page from which the PDF was generated.
Dependencies
- Puppeteer library (puppeteer-extra and puppeteer-extra-plugins)
Troubleshooting
- Ensure the URL is valid and accessible; invalid URLs cause request failures.
- Check that the Puppeteer browser launches correctly; errors in launching or connecting to the browser will throw errors.
- If the PDF generation fails, verify the PDF options such as page size, margins, and header/footer templates are correctly set.
- Container environments require specific Chrome launch arguments; disable container arguments only if launch issues occur.
- Timeouts can cause navigation failures; adjust timeout settings if pages take longer to load.
Links
- Puppeteer Documentation - Official Puppeteer documentation for browser automation and PDF generation.