Overview
This node generates PDF documents using the N8N Tools platform. It supports three main operations:
- Generate a PDF from raw HTML content.
- Generate a PDF from a predefined template populated with JSON data.
- Generate a PDF from a webpage URL.
The "Generate from URL" operation converts a live webpage into a PDF, allowing customization of paper size, orientation, margins, and other print options.
Common scenarios:
- Archiving or sharing web pages as PDFs for offline reading or record keeping.
- Automating report generation by converting dashboards or analytics pages to PDF.
- Creating printable versions of dynamic web content without manual intervention.
Example:
Convert a product page URL into a PDF brochure with A4 format, portrait orientation, and custom margins, optionally including headers and footers.
Properties
| Name | Meaning |
|---|---|
| URL | The webpage URL to convert into a PDF document. This is required. |
| Options | Collection of optional settings to customize the PDF output: |
| - Filename | Name of the generated PDF file (default: "document.pdf"). |
| - Format | Paper format for the PDF. Options: A4, A3, Letter, Legal (default: A4). |
| - Orientation | Page orientation. Options: Portrait, Landscape (default: Portrait). |
| - Include Header | Whether to include a header in the PDF (boolean, default: false). |
| - Include Footer | Whether to include a footer in the PDF (boolean, default: false). |
| - Margin Top | Top margin of the page, e.g., "1cm", "10px" (default: "1cm"). |
| - Margin Bottom | Bottom margin of the page, e.g., "1cm", "10px" (default: "1cm"). |
| - Margin Left | Left margin of the page, e.g., "1cm", "10px" (default: "1cm"). |
| - Margin Right | Right margin of the page, e.g., "1cm", "10px" (default: "1cm"). |
| - Print Background | Whether to include background graphics in the PDF (boolean, default: true). |
| - Wait Delay (ms) | Time in milliseconds to wait before generating the PDF, allowing the page to fully load (default: 3000 ms). |
| - Emulated Media Type | Media type to emulate when rendering the page. Options: Screen, Print (default: Screen). |
Output
The node outputs an array of items, each containing:
json: Metadata about the generated PDF:
success: Boolean indicating if PDF generation succeeded.filename: The name of the generated PDF file.size: Size of the PDF in bytes.operation: The operation performed ("generateFromUrl" here).- Additional metadata related to API usage such as credits used, remaining credits, cost in USD, operation cost, and any budget alerts/messages.
binary.data: The actual PDF file content encoded as binary data, ready for further use or saving.
Dependencies
- Requires an API key credential for the N8N Tools platform to authenticate requests.
- Uses the N8N Tools API endpoint to generate PDFs.
- The node makes HTTP POST requests to the API, sending parameters and receiving PDF data.
- No additional external dependencies beyond the configured API credentials.
Troubleshooting
Common issues:
- Invalid or missing URL parameter will cause failure.
- Network or authentication errors if the API key or endpoint is misconfigured.
- If the webpage takes too long to load, the PDF might be incomplete; adjust the "Wait Delay" accordingly.
- Incorrect margin or format values may lead to unexpected PDF layouts.
Error messages:
"PDF generation failed: <error message>"indicates an issue during the API call or processing.- Credential errors if the API key is invalid or missing.
- Template ID errors if using other operations but not relevant here.
Resolutions:
- Verify the URL is correct and accessible.
- Check API key validity and permissions.
- Increase the wait delay if the page has dynamic content loading.
- Ensure margin and format inputs are valid strings and options.
Links and References
- N8N Tools Platform Documentation
- Puppeteer PDF Options Reference (for understanding PDF formatting options)
- Axios HTTP Client (used internally for API calls)