Actions40
- AI Actions
- Business Actions
- Calculate Actions
- Code Actions
- Convert Actions
- Crypto Actions
- Generate Actions
- Operator Actions
- PDF Actions
- Storage Actions
Overview
The PDF: HTML to PDF operation in this custom n8n node allows you to convert either a web page (via URL) or raw HTML code into a PDF document. This is useful for automating the generation of PDFs from dynamic content, such as invoices, reports, or any web-based information that needs to be archived or shared in a portable format.
Common scenarios:
- Generating printable invoices from HTML templates.
- Archiving web pages as PDFs for compliance or record-keeping.
- Creating downloadable reports from dynamically generated HTML content.
Practical examples:
- Convert an order confirmation page to PDF and email it to a customer.
- Save a rendered dashboard as a PDF at scheduled intervals.
- Turn user-submitted HTML forms into standardized PDF documents.
Properties
| Name | Meaning |
|---|---|
| URL or HTML Code | Choose whether to provide a URL to fetch HTML from, or paste raw HTML code directly. Options: URL, HTML |
| URL | The web address of the page to convert to PDF. Required if "URL or HTML Code" is set to URL. |
| HTML Code | The raw HTML markup to convert to PDF. Required if "URL or HTML Code" is set to HTML. |
| Options | Additional PDF rendering options: - PDF Format: Paper size ( A0, A1, A2, A3, A4, A5, A6, Ledger, Legal, Letter, Tabloid). Defaults to Letter.- Scale: Rendering scale (0.1–2). - Landscape: Use landscape orientation. - Print Background Graphics: Include background graphics in the PDF. |
| Get File as URL | If enabled, returns a URL to download the generated PDF instead of embedding the file directly in the output. |
Output
- The node outputs a JSON object containing the result of the PDF conversion.
- If Get File as URL is enabled, the output will include a field with a URL pointing to the generated PDF file.
- If not, the output may contain the PDF data directly (as binary or base64-encoded data), depending on the implementation of the underlying service.
Example output (when Get File as URL is true):
{
"url": "https://example.com/generated/file.pdf"
}
Example output (when Get File as URL is false):
{
"pdf": "<base64-encoded-pdf-data>"
}
(Actual field names may vary depending on the backend response.)
Dependencies
- External Service: Requires access to the CodeKit API (or similar backend service).
- API Key/Credentials: You must configure the
codeKitApicredential in n8n for authentication. - n8n Configuration: No special environment variables are required beyond standard credential setup.
Troubleshooting
Common issues:
- Invalid URL or HTML: If the provided URL is unreachable or the HTML code is malformed, the conversion may fail.
- Missing Credentials: If the
codeKitApicredential is not configured, the node will throw an authentication error. - Large HTML Content: Very large HTML documents may exceed service limits and cause errors or timeouts.
- Incorrect Option Values: Setting an invalid scale (outside 0.1–2) or unsupported paper format may result in errors.
Error messages and resolutions:
"error":"Request failed with status code 401": Check your API credentials."error":"Invalid HTML input": Ensure your HTML code is valid and complete."error":"URL not reachable": Verify the URL is correct and accessible from the server running n8n.
Links and References
- n8n Documentation
- Puppeteer PDF Options Reference (for understanding PDF rendering options)
- CodeKit Node GitHub Repository (if available)