PDF4me icon

PDF4me

Comprehensive PDF and document processing: generate barcodes, convert files, extract data, manipulate images, and automate workflows with the PDF4ME API

Actions80

Overview

This node operation, Generate Document Single, allows users to generate a single document by merging a template file with provided data. It supports various input methods for both the template and the data, including binary data from previous nodes, base64 encoded strings, or URLs. The node can handle different template file types such as Word (Docx), HTML, and PDF, and it outputs the generated document in multiple formats like PDF, Word, Excel, or HTML.

Common scenarios where this node is beneficial:

  • Automating the creation of personalized documents such as contracts, invoices, or reports by filling templates with dynamic data.
  • Generating documents on-the-fly in workflows that require document customization based on user input or external data sources.
  • Converting structured data (JSON or XML) into formatted documents using predefined templates.

Practical example:
A workflow receives customer order data in JSON format and uses a Word template stored as binary data from a previous node. This node merges the order data into the template to produce a customized invoice in PDF format, which can then be sent to the customer.

Properties

Name Meaning
Template File Input Type How to provide the template file. Options: Binary Data (from previous node), Base64 String (encoded content), URL (link to the template file).
Template Binary Property Name of the binary property containing the template file (used if Template File Input Type is Binary Data).
Template File Name Name of the template file including extension (used if Template File Input Type is Binary Data, Base64 String, or URL).
Template Base64 Content Base64 encoded content of the template file (used if Template File Input Type is Base64 String).
Template File URL URL of the template file (used if Template File Input Type is URL).
Template File Type Type of the template file. Options: Word (Docx), HTML, PDF.
Document Data Input Type How to provide the document data to merge into the template. Options: Text (manual JSON or XML entry), Binary Data (from previous node), Base64 String, URL.
Document Data Type Format of the document data. Options: JSON, XML.
Document Data Text Manual entry of document data in JSON or XML format (required if Document Data Input Type is Text).
Document Binary Property Name of the binary property containing the data file (used if Document Data Input Type is Binary Data).
Document Data File Name Name of the data file including extension (used if Document Data Input Type is Binary Data, Base64 String, or URL).
Document Base64 Content Base64 encoded content of the data file (used if Document Data Input Type is Base64 String).
Document Data File URL URL of the data file (used if Document Data Input Type is URL).
File Meta Data Additional metadata for fields in JSON format to customize the document generation process.
Output Type Desired output file format of the generated document. Options: PDF, Word (Docx), Excel, HTML.
Meta Data Json Metadata in JSON format to influence document generation (required).

Output

The node outputs a single generated document file merged from the template and the provided data. The output includes:

  • A json field containing metadata or status information about the generated document.
  • A binary data property containing the generated document file in the selected output format (PDF, Word, Excel, or HTML).

If the output is binary, it represents the actual generated document file ready for further processing or download.

Dependencies

  • Requires access to the template file and data file either via binary data from previous nodes, base64 encoded strings, or accessible URLs.
  • May require an API key or authentication token configured in n8n to interact with the underlying document generation service (not explicitly shown in the code but typical for such integrations).
  • Proper configuration of environment variables or credentials for accessing external URLs if used.

Troubleshooting

  • Common issues:

    • Incorrect or missing template or data file inputs leading to errors in document generation.
    • Malformed JSON or XML in manual data entry causing parsing failures.
    • Invalid URLs or inaccessible resources when providing template or data files via URL.
    • Mismatch between template file type and specified template file name or content.
  • Error messages and resolutions:

    • Errors related to missing binary properties: Ensure the correct binary property names are specified and that the previous node outputs the expected binary data.
    • Parsing errors for JSON/XML data: Validate the syntax of manually entered data or the contents of the data files.
    • Network errors fetching files from URLs: Verify URL accessibility and network permissions.
    • Unsupported file type errors: Confirm that the template and output file types are among the supported options.

Links and References

Discussion