N8N Tools PDF Generator icon

N8N Tools PDF Generator

Generate PDFs using N8N Tools platform

Overview

This node generates PDF documents using the N8N Tools platform. It supports three main operations:

  • Generate from Template: Create a PDF by populating a predefined template with JSON data.
  • (Other operations exist but are out of scope for this summary.)

The "Generate from Template" operation is useful when you have standardized document layouts (e.g., invoices, reports, contracts) and want to dynamically fill them with specific data to produce consistent PDFs automatically.

Practical example:
You maintain a Word-based invoice template on the N8N Tools platform. Using this node, you can input customer and order details as JSON, select the invoice template, and generate a ready-to-send PDF invoice without manual editing.

Properties

Name Meaning
Template Select a predefined template either from a searchable list or by entering its ID directly.
Template Data JSON object containing key-value pairs used to populate variables in the selected template.
Options Collection of optional settings affecting PDF output:
- Filename Name of the generated PDF file (default: document.pdf).
- Format Paper size format; options: A4, A3, Letter, Legal (default: A4).
- Orientation Page orientation; options: Portrait, Landscape (default: Portrait).
- Include Header Whether to include a header section in the PDF (default: false).
- Include Footer Whether to include a footer section in the PDF (default: false).
- Margin Top Top margin size (e.g., "1cm", "10px") (default: "1cm").
- Margin Bottom Bottom margin size (default: "1cm").
- Margin Left Left margin size (default: "1cm").
- Margin Right Right margin size (default: "1cm").

Output

The node outputs an array of items, each containing:

  • json: Metadata about the generated PDF including:
    • success: Boolean indicating if generation succeeded.
    • filename: The name of the generated PDF file.
    • size: Size of the PDF in bytes.
    • operation: The operation performed (generateFromTemplate).
    • Usage and cost-related headers 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 fetch templates and generate PDFs.
  • Relies on external HTTP requests via Axios and FormData libraries internally.

Troubleshooting

  • Common issues:

    • Missing or invalid template ID: Ensure the template ID is correctly provided either by selecting from the list or entering a valid string.
    • Invalid JSON in Template Data: The node attempts to parse the JSON string; malformed JSON will cause errors.
    • API authentication failures: Verify that the API key credential is set up correctly and has necessary permissions.
    • Network or API errors: Check connectivity and API service status.
  • Error messages:

    • "Template ID is required": Occurs if no valid template ID is provided.
    • "PDF generation failed: <error message>": Generic failure during PDF creation; check error details for specifics.
  • Resolution tips:

    • Validate JSON input before running the node.
    • Confirm API credentials and endpoint URL.
    • Use the "Continue On Fail" option to handle errors gracefully in workflows.

Links and References

Discussion