PDF Generator API icon

PDF Generator API

Generate PDFs, manage templates, convert HTML/URLs to PDF, and perform PDF operations like watermarking, encryption, and optimization

Overview

This node integrates with a PDF generation API to convert HTML content into PDF documents. It is designed for users who need to programmatically generate PDFs from custom HTML markup, supporting various page sizes and orientations. The node can output the generated PDF either as a base64-encoded JSON string or as a binary file suitable for download or further processing.

Common scenarios include:

  • Generating invoices, reports, or certificates dynamically from HTML templates.
  • Creating styled PDF documents with custom fonts, tables, images, and layouts.
  • Automating document creation workflows where HTML content is produced by other systems or user input.

Example: Convert an HTML invoice template into a PDF file named "invoice.pdf" with A4 paper size in portrait orientation, then use the PDF in subsequent automation steps.

Properties

Name Meaning
HTML Content The HTML markup to convert into a PDF. Must be at least 10 characters long. Supports inline CSS styling.
Filename The desired filename for the generated PDF (without the .pdf extension). Allowed characters: letters, numbers, dots, hyphens, underscores. Cannot be empty.
Additional Options Collection of optional settings:
• Paper Size: Choose from A0, A1, A2, A3, A4 (default), Legal, Letter, Tabloid.
• Orientation: Portrait (default) or Landscape.
• Output Format: Base64 (JSON) or File (Binary). Default is Base64.

Output

The node outputs one item per input with the following structure depending on the selected output format:

  • Base64 (JSON):
    The json field contains:

    • success: boolean indicating operation success.
    • filename: the PDF filename with .pdf extension.
    • format: output format (base64).
    • A base64 string representing the PDF content.
  • File (Binary):
    The output includes a binary property containing the PDF file data under a key named after the filename with .pdf extension. The json field includes metadata such as:

    • success: true
    • filename
    • format (file)
    • fileSize: size of the PDF in bytes

This binary output is suitable for direct download or passing to other nodes that handle files.

Dependencies

  • Requires an API key credential for the connected PDF generation service.
  • The node makes authenticated HTTP requests to the external PDF Generator API endpoint.
  • No additional environment variables are needed beyond the API credential configuration.

Troubleshooting

  • HTML Content Validation:
    If the HTML content is missing or shorter than 10 characters, the node throws an error. Ensure your HTML input is valid and sufficiently long.

  • Filename Restrictions:
    Filenames must not be empty and can only contain letters, numbers, dots, hyphens, and underscores. Violations cause validation errors.

  • URL Validation (if URL to PDF used):
    URLs must start with http:// or https://. Invalid URLs will trigger errors.

  • API Authentication Errors:
    If the API key is invalid or missing, requests will fail. Verify the API credential setup in n8n.

  • Output Format Issues:
    Selecting binary output requires proper handling downstream; otherwise, the data may not be usable.

  • Network or API Errors:
    Network issues or API downtime can cause request failures. Check connectivity and API status.

Links and References


This summary covers the "Conversion" resource with the "HTML to PDF" operation, focusing on the node's execute logic, inputs, outputs, and usage considerations.

Discussion