Generate Document (Single) using n8n action
PDF4me Generate Document (Single) creates personalized documents from templates using dynamic data through n8n automation workflows. Process templates (Word, HTML, PDF) via n8n triggers, binary data, base64 strings, or public URLs with JSON/XML data to generate customized documents with intelligent data merging, variable replacement, conditional content, formatting preservation, and multiple output formats (PDF, Word, Excel, HTML). This solution is ideal for personalized letters, invoices, contracts, reports, certificates, and automated document generation workflows that require template-based creation with accurate data integration and seamless integration.
Setup
Add the PDF4me "Generate Document (Single)" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.
Prerequisites:
- PDF4me API credentials
- n8n workflow access
Configuration:
- Add PDF4me node to workflow
- Select "Generate Document (Single)" action
- Configure input parameters (see below)
/generate document single.webp)
Parameters
Complete list of parameters for the Generate Document (Single) action. Configure these parameters to control single document generation from templates.
Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.
| Parameter | Type | Description | Example |
|---|---|---|---|
| Template File Input Type*** | String | Template Input Format Selection • Choose the format of your template file data input • PDF4me supports multiple input types • Options: Binary Data, Base64 String, or URL | Binary Data |
| Template Binary Property | String | Template Binary Data Reference (Required if Binary Data) • Specify the property name for accessing binary template data • Should match the binary data property name in your workflow • Required when Template File Input Type is "Binary Data" | data |
| Base64 Template Content | String | Base64 Encoded Template Input (Required if Base64 String) • Provide template file data as base64 encoded string • PDF4me automatically decodes and processes the template content • Required when Template File Input Type is "Base64 String" | UEsDBBQABgAI... |
| Template File URL | String | Public Template URL Input (Required if URL) • Provide a public/open permission URL to the template file • PDF4me downloads and processes the template from the provided URL • Required when Template File Input Type is "URL" | https://abc.com/temp.docx |
| Template File Name*** | String | Template Filename Specification • Specify the name of the template file with proper extension • Supports .docx, .html, .pdf file types • Helps with file identification and processing order | template.docx |
| Template File Type*** | String | Template File Type Selection • Choose the type of template file being processed • PDF4me supports different template types with specific requirements • Options: Word (.docx), HTML (.html), PDF (.pdf) | Word |
| Document Data Input Type*** | String | Data Input Format Selection • Choose the format of your document data input • PDF4me supports multiple input types • Options: Text, Binary Data, or URL | Text |
| Document Data Type*** | String | Data Format Selection • Choose the format of your document data • PDF4me supports JSON and XML data formats • Used for template processing and field population | JSON |
| Document Data Text | String | Manual Data Input • Manually enter the data for the template in JSON or XML format • Required only if data file is not mapped through other methods • Used for direct data entry | {"name": "John Doe", "email": "[email protected]", "amount": 1500.00} |
| Document Data File | String | Data File Binary Reference (Required if Binary Data) • Specify the property name for accessing binary data file • Should match the binary data property name in your workflow • Required when Document Data Input Type is "Binary Data" | data |
| Document Data URL | String | Public Data URL Input (Required if URL) • Provide a public/open permission URL to the data file • PDF4me downloads and processes the data from the provided URL • Required when Document Data Input Type is "URL" | https://exam.com/abc.json |
| Output Type*** | String | Output Format Selection • Choose the file format of the generated document • PDF4me supports multiple output formats • Options: PDF, Word (.docx), Excel (.xlsx), HTML | PDF |
| Meta Data Json*** | String | Metadata JSON Specification • JSON metadata for the generated document • Can include document properties, processing information, custom attributes • Essential for document metadata management | {"title": "Generated Document", "author": "PDF4me", "subject": "Template Processing"} |
| Binary Data Output Name*** | String | Binary Data Mapping • Define the variable name for accessing generated document binary data • Used in subsequent workflow actions • Essential for workflow data flow | data |
| File Meta Data | String | Additional Metadata • Additional metadata for fields in JSON format • Can include custom properties, formatting instructions, processing hints • Optional for advanced template processing | {"department": "Sales", "priority": "High", "version": "1.0"} |
Advanced Options
The following parameters are available in the Advanced Options section and are optional:
| Parameter | Type | Description | Example |
|---|---|---|---|
| Custom Profiles | String | Custom Configuration Profiles • Set additional options using custom profiles • JSON-like format containing predefined parameters • Supports outputDataFormat, preserveMetadata, etc. • Optional for specialized requirements | { "outputDataFormat": "base64", "preserveMetadata": true, "optimizeForPrinting": false, "compressionLevel": "medium" } |
Output
Output Parameters
| Parameter | Type | Description | Example |
|---|---|---|---|
| success | Boolean | PDF4me document generation operation status indicator - Boolean flag indicating the success or failure of the document generation process. PDF4me returns true for successful operations and false for any errors, enabling robust error handling in automated workflows | true |
| message | String | PDF4me document generation operation status message - Human-readable status message providing details about the document generation process result. Includes success confirmation or error details for troubleshooting | Document generated successfully |
| fileName | String | PDF4me generated document filename - The complete filename of the successfully generated document with proper file extension. PDF4me ensures unique naming and validates file format compliance for seamless integration with downstream processes | generated_document.pdf |
| mimeType | String | PDF4me output MIME type - MIME type of the generated document based on the selected output format. Useful for content type validation and proper file handling in web applications | application/pdf |
| fileSize | Number | PDF4me generated document file size in bytes - The exact size of the generated document in bytes, provided by PDF4me for storage planning, bandwidth optimization, and file transfer monitoring. Essential for enterprise document management and workflow automation | 125430 |
| docName | String | PDF4me document name reference - The name of the generated document for reference and tracking purposes. This matches the fileName for consistency in document management workflows | generated_document.pdf |
| documentGenerated | Boolean | PDF4me document generation completion confirmation - Boolean flag confirming that the document generation operation has been successfully completed. Useful for verifying that the document was generated correctly | true |
| templateProcessed | Boolean | PDF4me template processing confirmation - Boolean flag confirming that the template was successfully processed and data was merged correctly. Useful for verifying template processing effectiveness | true |
N8N Action Response
The PDF4me Generate Document (Single) API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:
- JSON
- Table
- Schema
- Binary
JSON Response Format
The raw JSON response from the API:
[
{
"success": true,
"message": "Document generated successfully",
"fileName": "generated_document.pdf",
"mimeType": "application/pdf",
"fileSize": 125430,
"docName": "generated_document.pdf",
"documentGenerated": true,
"templateProcessed": true
}
]
Table View
Response data in a structured table format:
| Parameter | Value |
|---|---|
| success | true |
| message | Document generated successfully |
| fileName | generated_document.pdf |
| mimeType | application/pdf |
| fileSize | 125430 |
| docName | generated_document.pdf |
| documentGenerated | true |
| templateProcessed | true |
Schema View
The data structure and types of the response:
1 item
success: ☑ true
message: AB Document generated successfully
fileName: AB generated_document.pdf
mimeType: AB application/pdf
fileSize: # 125430
docName: AB generated_document.pdf
documentGenerated: ☑ true
templateProcessed: ☑ true
Type Indicators:
AB= String#= Number☑= Boolean
Binary Data View
The actual generated document file data and metadata:
data
─────────────────────────────
File Name: generated_document.pdf
File Extension: pdf
Mime Type: application/pdf
File Size: 122.5 KB
Binary Data Access:
- n8n Binary Object:
$binary.data.data - Base64 Content: Available for direct use
- File Operations: Ready for download, email, or storage
Use Cases
Personalized Document Generation and Automation
- Automatically generate personalized invoices, contracts, and business documents from templates using customer data from CRM systems or databases
- Process employee onboarding documents by generating personalized offer letters, contracts, and welcome packages using employee information from HR systems
- Create customized reports and presentations by merging data from various sources into professional document templates for different stakeholders
Template-Based Content Management
- Generate marketing materials and promotional documents from templates using dynamic product information, pricing data, and customer-specific content
- Process legal documents and compliance materials by generating personalized contracts, agreements, and legal forms using client data and case information
- Create educational materials and training documents by generating personalized certificates, course materials, and learning resources using student and course data
Business Process Automation and Workflow Integration
- Integrate document generation into business workflows by automatically creating documents based on workflow triggers, form submissions, or data updates
- Process batch document generation for large-scale operations like mass mailings, report generation, or document distribution using bulk data sources
- Automate the creation of standardized documents across different departments and teams while maintaining consistency and reducing manual effort