Actions2
Overview
This node converts HTML content or website URLs into PDF documents. It supports two main operations:
- HTML to PDF: Converts raw HTML and optional CSS styling into a PDF file.
- URL to PDF: Captures a screenshot of a full or partial webpage and saves it as a PDF.
This node is useful for automating the generation of PDFs from dynamic web content, such as creating reports, invoices, or archiving web pages. For example, you can input custom HTML templates with CSS styles to produce styled PDF documents, or capture live websites as PDFs for offline viewing or record keeping.
Properties
| Name | Meaning |
|---|---|
| Operation | Choose between "HTML to Pdf" (convert HTML/CSS to PDF) or "URL to Pdf" (capture website screenshot as PDF). |
| HTML Content | The raw HTML markup to convert into a PDF (used only in "HTML to Pdf" operation). |
| CSS Content | Optional CSS styles to apply to the HTML content before conversion (only for "HTML to Pdf"). |
| Viewport Width | Width in pixels of the viewport used when rendering the HTML or capturing the URL. |
| Viewport Height | Height in pixels of the viewport used when rendering the HTML or capturing the URL. |
| Response Format | Format of the output for "HTML to Pdf": URL link to PDF, PNG image, or Base64 encoded string. |
| URL | The website URL to capture as PDF (used only in "URL to Pdf" operation). |
| Full Page | Whether to capture the entire webpage or just the visible viewport (only for "URL to Pdf"). |
| Wait Till | Time in milliseconds to wait before capturing the webpage screenshot (only for "URL to Pdf"). |
Output
The node outputs JSON data containing the response from the PDF generation API. Depending on the chosen response format for the "HTML to Pdf" operation, the output may include:
- A URL pointing to the generated PDF or image.
- A PNG image representation.
- A Base64 encoded string of the PDF/image.
For the "URL to Pdf" operation, the output contains the PDF data or a link to the generated PDF file.
The exact structure depends on the external API response but generally includes fields representing the generated PDF or image resource.
Dependencies
- Requires an API key credential for authentication with the external PDF generation service at
https://pdfmunk.com/api/v1/generatePdf. - The node uses HTTP POST requests to this API endpoint to perform conversions.
- Proper configuration of the API key credential within n8n is necessary for successful execution.
Troubleshooting
Common issues:
- Invalid or missing API key credential will cause authentication failures.
- Incorrect HTML or CSS syntax might result in malformed PDFs or errors.
- Network connectivity problems can prevent reaching the external API.
- Setting very small viewport dimensions may produce incomplete or distorted PDFs.
- Waiting time (
wait_till) too short for complex webpages may lead to incomplete captures.
Error messages:
- Errors returned by the external API are passed through; check the error message for details.
- Node operation errors include the item index to help identify which input caused the failure.
- To continue processing other items despite errors, enable "Continue On Fail" in the node settings.
Links and References
- PDFMunk API Documentation (for detailed API usage and options)
- n8n HTTP Request Node Documentation (for understanding HTTP request handling)
- HTML to PDF Conversion Concepts (general background on HTML to PDF techniques)