Generate Documents (Multiple) in n8n
Generate Documents Multiple is a PDF4me node action in n8n, shown in the node as Generate Documents (Multiple), that renders many finished files in one run from a single template plus an array of records. Use it for a batch of invoices, customer letters, or per-region reports, with each document returned as its own n8n item.
What this node does
PDF4me: Generate Documents (Multiple) takes one template and a list of records and produces many finished documents in one n8n run. Provide a Word, HTML, or PDF template via Binary Data, Base64, HTML code, or URL plus bulk data as JSON or XML (array of records or repeating XML). Each generated file returns as a separate output item so you can loop, save, email, or upload them individually. Use this node instead of Generate Document (Single) whenever you have a list of customers, invoices, or records and want one finished document per row in a single execution.
Authenticating Your API Request
Every PDF4me node in n8n requires a valid Credential to connect with. Create or select one that holds your PDF4me API key so the workflow can authenticate batch document generation requests securely.
Important Facts You Should Not Miss
/generate-documents-multiple-full.png)
Full node panel. Word template + JSON Text data + PDF output is the typical mail-merge setup
Generate Documents (Multiple) vs Generate Document (Single)
Picking the wrong one of the two is the most common mistake on this task. The split is about how many files come back and which template and data formats are on offer.
| Aspect | Generate Documents (Multiple) | Generate Document (Single) |
|---|---|---|
| Files returned | Many, one n8n item per generated document | Exactly one |
| Template types | Word, HTML, PDF | Word, HTML, PDF, plus Mail Merge and Google Docs |
| Data formats | JSON or XML only | JSON, XML, and CSV |
| Output types | PDF, Word, or Excel (HTML templates output HTML) | PDF, Word (no Excel option) |
| Reach for it when | You have a list of records and want one document per row | You have a single record, CSV data, or a Mail Merge template |
What Parameters Does Generate Documents (Multiple) Need?
Required in the n8n UI: Credential to connect with, Template File Type, Template File Input Type, Document Data Type, Document Data Input Type, and Output Type (always shown. choices depend on Template File Type). Conditional required fields (Template Binary Property, Template Base64 Content, HTML Code, Template File URL, Document Data Text, Document Binary Property, etc.) appear only when their parent input type is chosen. Output File Name, Keep PDF Editable, and Binary Data Output Name are optional with sensible defaults.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| Template File Type | Required | Format of the template the node will render. Word for .docx templates, HTML for HTML templates (including pasted code), PDF for PDF templates. There is no Mail Merge, Google Docs, or PDF form option here; use Generate Document (Single) for those. | Word |
| Output Type | Required | Format of every generated document. Word and PDF templates accept PDF, Word, or Excel. HTML templates accept HTML only. Default is PDF when available. | PDF |
| Template File Input Type | Required | How the template is supplied. Binary Data reads from a previous node (most common). Base64 String accepts an encoded template. HTML Code accepts pasted raw HTML (only valid when Template File Type is HTML). URL downloads the template from a public link. | Binary Data |
| Template Binary Property | Conditional | Name of the binary property on the incoming n8n item that holds the template. Required when Template File Input Type is Binary Data. Defaults to data. | data |
| Template Base64 Content | Conditional | Base64-encoded template content. Required when Template File Input Type is Base64 String. | UEsDBBQAAAAI... |
| HTML Code | Conditional | Raw HTML body (mustache placeholders such as {{title}} are supported). Required when Template File Input Type is HTML Code, which is only valid for Template File Type HTML. The node wraps the snippet in a basic <html> shell if missing. | <h1>{{title}}</h1> |
| Template File URL | Conditional | Publicly reachable HTTPS URL to the template file. Required when Template File Input Type is URL. | https://example.com/template.docx |
| Template File Name | Conditional | Filename of the template. Optional with Binary Data (falls back to the uploaded filename or a sensible default such as template.docx, template.html, template.pdf). Required for Base64 String, HTML Code, and URL. | template.docx |
| Document Data Type | Required | Format of the bulk records you are sending. JSON for arrays of objects (most common). XML for repeating-record XML. CSV is not available on this operation. | JSON |
| Document Data Input Type | Required | How the bulk data is supplied. Text is the default (paste JSON or XML directly). Binary Data reads from a previous node. Base64 String accepts an encoded data file. URL downloads the data file from a public link. | Text |
| Document Data Text | Conditional | Raw bulk JSON or XML payload. Required when Document Data Input Type is Text. The node validates that JSON parses; XML is sent as-is. Use an array of objects in JSON so the API renders many files. | [{"name":"Alice"},{"name":"Bob"}] |
| Document Binary Property | Conditional | Name of the binary property on the incoming n8n item that holds the data file. Required when Document Data Input Type is Binary Data. Defaults to data. | data |
| Document Data File Name | Conditional | Filename for the bulk data file. Optional with Binary Data (falls back to data.json). Required when Document Data Input Type is Base64 String or URL. | customers.json |
| Document Base64 Content | Conditional | Base64-encoded data file. Required when Document Data Input Type is Base64 String. | W3sibmFtZSI6... |
| Document Data File URL | Conditional | Publicly reachable HTTPS URL to the bulk data file. Required when Document Data Input Type is URL. | https://example.com/customers.json |
| Output File Name | Optional | Prefix for the generated filenames. The node appends _1, _2, ... and the correct extension. Example: invoice becomes invoice_1.pdf, invoice_2.pdf. Leave blank to use API-provided names or generated_document_1, generated_document_2, ... | invoice |
| Keep PDF Editable | Optional | Only shown when Output Type is PDF. Keeps AcroForm fields editable on every generated PDF when enabled. Default is off (flattened output). | Off |
| Binary Data Output Name | Optional | Name of the binary property each output item exposes. Default is data. Placeholder suggests generated-documents. | data |
Template File Type Options
Choose the template format. Output Type choices change with this selection.
/generate-documents-multiple-template-file-type.png)
Template File Type dropdown. Word, HTML, or PDF (no Mail Merge or Google Docs here)
WordDefault: .docx templatesHTMLHTML templates and pasted HTML codePDFPDF templatesOutput Type by Template
| Template File Type | Output Type choices | Default |
|---|---|---|
| Word | PDF, Word, Excel | |
| PDF, Word, Excel | ||
| HTML | HTML only | HTML |
Template File Input Type Options
Pick how the template enters the node. The follow-up fields change with this choice.
/generate-documents-multiple-template-file-input-type.png)
Template File Input Type. Binary Data, Base64 String, HTML Code, or URL
Binary DataDefault: file from previous nodeTemplate Binary Property to the binary field name (default data). Template File Name is optional and falls back to the uploaded filename.Base64 StringBase64-encoded templateTemplate Base64 Content. Template File Name is required so the extension matches the Template File Type (.docx, .html, .pdf).HTML CodePaste raw HTML inline (HTML only){{title}}, {{content}} into HTML Code. The node wraps it in a basic <html> shell if missing. Template File Name is required (e.g. template.html).URLDownload from a public linkTemplate File URL. PDF4me fetches the template directly. The URL must be open (no auth) and Template File Name is required so the extension matches the template type.Document Data Type Options
Pick the data format you are sending.
/generate-documents-multiple-document-data-type.png)
Document Data Type. JSON or XML (no CSV in this operation)
JSONDefault: array of records (most common)[{"name":"Alice"}, {"name":"Bob"}]. The node validates that the payload parses. A single object generates one document. pass an array if you want many.XMLRepeating-record XMLDocument Data Input Type Options
Pick how the bulk data enters the node.
/generate-documents-multiple-document-data-input-type.png)
Document Data Input Type. Text, Binary Data, Base64 String, or URL
TextDefault: paste bulk data inlineDocument Data Text. This field is strictly required on the Multiple operation when Text is chosen (stricter than Single).Binary DataUse a data file from a previous nodeDocument Binary Property to the binary field name (default data). Watch that the template and data binary property names do not collide when both come from the same item.Base64 StringBase64-encoded data file.json or .xml file as base64 in Document Base64 Content. Document Data File Name is required.URLDownload from a public linkDocument Data File URL to a public HTTPS URL of the JSON or XML data file. Document Data File Name is required so the extension matches the data type.Output File Name behaviour
| Scenario | Output File Name | Generated filenames |
|---|---|---|
| One document returned | invoice | invoice.pdf (extension added if missing) |
| Many documents returned | invoice | invoice_1.pdf, invoice_2.pdf, invoice_3.pdf, ... |
| Many documents, name left empty | (empty) | API-provided names or generated_document_1, generated_document_2, ... |
Output Fields
A successful run returns one n8n item per generated document. Each item carries both JSON metadata and the binary file.
| Field | Type | What it contains |
|---|---|---|
success | Boolean | True when the document was generated successfully. Use to route error handling branches. |
fileName | String | Filename of this generated document, e.g. invoice_2.pdf. Map into upload or email nodes. |
mimeType | String | MIME type of the output file, e.g. application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/html. |
fileSize | Number | Size of the generated file in bytes. |
documentIndex | Number | Index of this document within the batch (1-based). Useful for filenames or logging. |
totalDocuments | Number | How many documents were produced in this run. Same on every item. |
Binary (data) | Binary | The generated document under Binary Data Output Name (default data). Pass to Write Binary File, Email, or any cloud-storage upload. |
How Do I Set Up Generate Documents (Multiple) in n8n?
- Add PDF4me to your n8n workflow. Set Resource to Generate and Generate Operations to Generate Documents (Multiple).
- In Credential to connect with, select your PDF4me credential or click Create New Credential and paste your API key.
- Set Template File Type to Word (default), HTML, or PDF.
- Set Output Type. PDF, Word, or Excel for Word / PDF templates; HTML only for HTML templates.
- Set Template File Input Type to Binary Data (default), Base64 String, HTML Code (HTML only), or URL and fill the matching template field plus Template File Name if required.
- Set Document Data Type to JSON (default) or XML.
- Set Document Data Input Type to Text (default) and paste your JSON array into Document Data Text. or pick Binary Data, Base64 String, or URL and supply the data file.
- Set Output File Name to something readable like
invoiceso files come back asinvoice_1.pdf,invoice_2.pdf, ... - If outputting PDF and your template has form fields, enable Keep PDF Editable.
- Leave Binary Data Output Name as
dataunless a downstream node needs a different property name. Execute the node and route the multiple output items into Split In Batches, Write Binary File, Email, or cloud-storage upload.
Typical Setups
Workflow ExamplesCommon n8n workflow patterns using Generate Documents (Multiple).
- A Google Sheets node pulls a list of customers with name, address, and balance into the workflow.
- A Code or Set node packages the rows into a JSON array of objects (one object per customer).
- PDF4me Generate Documents (Multiple) runs with Template File Type Word, Output Type PDF, Template File Input Type Binary Data, and Document Data Input Type Text. Output File Name is
customer_letter. - The node returns one item per customer named
customer_letter_1.pdf,customer_letter_2.pdf, and so on. - A Loop Over Items node sends each PDF to the matching customer via Gmail or uploads to Google Drive.
- One node downloads the .docx template; another node downloads the .json customers file. A Merge node combines them so both binaries land on one item.
- PDF4me Generate Documents (Multiple) is configured with Template File Input Type Binary Data (
Template Binary Propertyset to the template field name) and Document Data Input Type Binary Data (Document Binary Propertyset to the data field name). - Set
Document Data File Nameif the data file is not nameddata.json. - The generated files come back as separate items and are written to a SharePoint document library named after the customer ID.
- A nightly Schedule Trigger fires the invoice batch run.
- PDF4me Generate Documents (Multiple) is set with Template File Input Type URL (
Template File URLpoints to the .docx invoice template on S3) and Document Data Input Type URL (Document Data File URLpoints to a generatedbilling-cycle.jsonfile). Template File Nameisinvoice.docxandDocument Data File Nameisbilling-cycle.json.- Output Type is PDF, Output File Name is
invoice, and Keep PDF Editable is off. - Each returned item is uploaded to the customer's folder in Dropbox and emailed via Outlook.
- A Webhook Trigger fires when a marketing campaign launches.
- PDF4me Generate Documents (Multiple) is set with Template File Type HTML and Template File Input Type HTML Code. the HTML is pasted directly into the node with mustache placeholders.
- Document Data Type is JSON, Document Data Input Type is Text, and an expression maps the campaign's lead list into a JSON array.
- Output Type is HTML. The node returns one HTML file per lead.
- A Write Binary File node saves each generated HTML to a public web folder; another node sends the personalised link to each lead.
- A daily Schedule Trigger pulls KPI numbers from PostgreSQL.
- A Set node groups the rows by region into a JSON array, one record per region.
- PDF4me Generate Documents (Multiple) runs with Template File Type Word, Output Type Excel, Document Data Type JSON, Document Data Input Type Text. Output File Name is
region_report. - The node returns one .xlsx per region named
region_report_1.xlsx,region_report_2.xlsx, and so on. - A Microsoft OneDrive node uploads each file to the matching region folder for the analytics team.
Practical Tips
Cheat Sheet
| Field | Value |
|---|---|
| Resource | Generate |
| Operation | Generate Documents (Multiple) |
| Template File Type | Word |
| Output Type | PDF |
| Template File Input Type | Binary Data |
| Template Binary Property | data |
| Document Data Type | JSON |
| Document Data Input Type | Text |
| Document Data Text | (bulk JSON array with multiple records) |
| Output File Name | my_document (optional, becomes prefix) |
| Binary Data Output Name | data |
| Credentials | PDF4me API credential |
Frequently Asked Questions
Related Actions
Same Task on Other Platforms
POST /api/v2/GenerateDocumentMultiple endpoint. for custom backend code or Postman testing.