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 create documents from templates by merging them with user-provided JSON data. It supports generating PDFs or HTML documents based on predefined templates, allowing dynamic content creation for reports, invoices, certificates, contracts, and other document types.

Common scenarios include:

  • Automatically generating personalized PDF invoices or receipts using customer data.
  • Creating batch documents (e.g., certificates) for multiple recipients in one operation.
  • Generating documents asynchronously with callback notifications for long-running tasks.
  • Producing HTML output for previewing or embedding generated content in web pages.

Practical example:

  • A business uses this node to generate customized PDF contracts by selecting a contract template and providing client-specific data as JSON. The output can be returned as a Base64 string, a downloadable file, or a URL to the stored document.

Properties

Name Meaning
Template Select the template to use for document generation. Options: select from a list of templates or enter template ID directly (must be numeric).
Data JSON object containing the data to merge into the selected template for dynamic content population.
Format Output document format. Options: PDF, HTML.
Output Response format for generated document. Options: Base64 (JSON string), File (inline binary file), URL (document stored for 30 days).
Additional Fields Optional fields:
- Output Name: custom name for the generated document.
- Testing: boolean flag to enable testing mode (adds a large PREVIEW stamp and does not count towards usage).

Output

The node outputs an array of items, each containing:

  • json:
    • success: Boolean indicating if generation succeeded.
    • filename: The name of the generated document including extension.
    • format: The output format used (base64, file, or url).
    • Additional fields depending on output type:
      • For base64 or url: includes the base64 string or URL link.
      • For file: no direct JSON content of the file; instead, binary data is provided.
  • binary (only if output is file):
    • Contains the generated document as binary data keyed by the filename, ready for download or further processing in n8n.

If the output is a URL, it points to a document stored temporarily (30 days).

Dependencies

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

Troubleshooting

  • Invalid JSON in Data property: If the JSON data provided for merging is malformed, the node throws an error indicating the data must be valid JSON. Ensure the JSON syntax is correct.
  • Template ID validation: Template IDs must be numeric strings. Providing invalid IDs will cause validation errors.
  • Output format mismatch: Selecting File output returns binary data; ensure downstream nodes can handle binary files.
  • Testing mode: When enabled, generated documents have a large "PREVIEW" watermark and do not count against usage limits.
  • API connectivity issues: Errors related to authentication or network problems may occur if the API key is missing, invalid, or the service is unreachable.
  • Empty or missing required parameters: The node validates required inputs like template selection and data; missing these will cause errors.

Links and References

Discussion