Skip to main content

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.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog

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

One n8n item per generated document
A successful run usually returns multiple items, one per generated file. Each item carries the binary file under Binary Data Output Name and JSON metadata with documentIndex and totalDocuments so you can loop, save, or email each file individually downstream.
Pass an array (JSON) or repeating XML so the API knows how many files to render
For JSON, use an array of objects, one per generated document. For XML, use a repeating-record structure the template expects (mail-merge style). Single objects produce one document, which defeats the purpose of this operation.
CSV, Mail Merge, and Google Docs are not available here
Template File Type only offers Word, HTML, PDF. Document Data Type only offers JSON or XML. If you need CSV input or Mail Merge / Google Docs templates, use Generate Document (Single) instead.
Generate Documents (Multiple) n8n node showing Credential to connect with Pdf4me, Resource Generate, Generate Operations Generate Documents (Multiple), Template File Type Word, Output Type PDF, Template File Input Type Binary Data, Template Binary Property data, Template File Name template.docx, Document Data Type JSON, Document Data Input Type Text, sample Document Data Text, Output File Name generated_document, Keep PDF Editable toggle, Binary Data Output Name data

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.

AspectGenerate Documents (Multiple)Generate Document (Single)
Files returnedMany, one n8n item per generated documentExactly one
Template typesWord, HTML, PDFWord, HTML, PDF, plus Mail Merge and Google Docs
Data formatsJSON or XML onlyJSON, XML, and CSV
Output typesPDF, Word, or Excel (HTML templates output HTML)PDF, Word (no Excel option)
Reach for it whenYou have a list of records and want one document per rowYou 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.

ParameterRequiredWhat it doesExample
Template File TypeRequiredFormat 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 TypeRequiredFormat 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 TypeRequiredHow 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 PropertyConditionalName 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 ContentConditionalBase64-encoded template content. Required when Template File Input Type is Base64 String.UEsDBBQAAAAI...
HTML CodeConditionalRaw 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 URLConditionalPublicly reachable HTTPS URL to the template file. Required when Template File Input Type is URL.https://example.com/template.docx
Template File NameConditionalFilename 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 TypeRequiredFormat 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 TypeRequiredHow 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 TextConditionalRaw 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 PropertyConditionalName 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 NameConditionalFilename 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 ContentConditionalBase64-encoded data file. Required when Document Data Input Type is Base64 String.W3sibmFtZSI6...
Document Data File URLConditionalPublicly reachable HTTPS URL to the bulk data file. Required when Document Data Input Type is URL.https://example.com/customers.json
Output File NameOptionalPrefix 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 EditableOptionalOnly 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 NameOptionalName 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.

Template File Type dropdown in n8n PDF4me Generate Documents (Multiple) node showing three options: Word highlighted, HTML, and PDF

Template File Type dropdown. Word, HTML, or PDF (no Mail Merge or Google Docs here)

WordDefault: .docx templates
Standard PDF4me Word template with mustache placeholders. Output Type can be PDF, Word, or Excel. Most common choice for batch invoices, customer letters, and personalised reports.
HTMLHTML templates and pasted HTML code
Renders HTML templates with mustache placeholders. Output Type is HTML only. Pair with Template File Input Type HTML Code to paste raw HTML inline, or use Binary Data / URL for a hosted .html file.
PDFPDF templates
Use an existing PDF as the template. Output Type can be PDF, Word, or Excel. For PDF output, enable Keep PDF Editable if you want fields editable on every generated file.

Output Type by Template

Template File TypeOutput Type choicesDefault
WordPDF, Word, ExcelPDF
PDFPDF, Word, ExcelPDF
HTMLHTML onlyHTML

Template File Input Type Options

Pick how the template enters the node. The follow-up fields change with this choice.

Template File Input Type dropdown in n8n PDF4me Generate Documents (Multiple) node showing four options: Binary Data highlighted with description Use template file from previous node, Base64 String with description Provide base64 encoded template file, HTML Code with description Write raw HTML code manually only available for HTML template type, URL with description Provide a URL to the template file

Template File Input Type. Binary Data, Base64 String, HTML Code, or URL

Binary DataDefault: file from previous node
Reads the template directly from a prior node such as Google Drive Download, HTTP Request, or Read Binary File. Set Template Binary Property to the binary field name (default data). Template File Name is optional and falls back to the uploaded filename.
Base64 StringBase64-encoded template
Paste or map a base64 string into Template 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)
Only valid when Template File Type is HTML. Paste full or partial HTML with placeholders like {{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 link
Provide an HTTPS URL in Template 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.

Document Data Type dropdown in n8n PDF4me Generate Documents (Multiple) node showing JSON highlighted and XML as the two options. Tooltip reads Parameter documentDataType

Document Data Type. JSON or XML (no CSV in this operation)

JSONDefault: array of records (most common)
Use a JSON array where each object is one generated document, e.g. [{"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 XML
Use an XML structure your template expects for repeating rows (mail-merge style). The node does not perform deep validation. make sure the XML matches the template's bind points.

Document Data Input Type Options

Pick how the bulk data enters the node.

Document Data Input Type dropdown in n8n PDF4me Generate Documents (Multiple) node showing four options: Text highlighted with description Manually enter JSON or XML data, Binary Data with description Use data file from previous node, Base64 String with description Provide base64 encoded data file, URL with description Provide a URL to the data file

Document Data Input Type. Text, Binary Data, Base64 String, or URL

TextDefault: paste bulk data inline
Type or expression-map the full JSON array or XML into Document 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 node
Set Document 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
Provide the entire .json or .xml file as base64 in Document Base64 Content. Document Data File Name is required.
URLDownload from a public link
Set Document 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

ScenarioOutput File NameGenerated filenames
One document returnedinvoiceinvoice.pdf (extension added if missing)
Many documents returnedinvoiceinvoice_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.

FieldTypeWhat it contains
successBooleanTrue when the document was generated successfully. Use to route error handling branches.
fileNameStringFilename of this generated document, e.g. invoice_2.pdf. Map into upload or email nodes.
mimeTypeStringMIME type of the output file, e.g. application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, text/html.
fileSizeNumberSize of the generated file in bytes.
documentIndexNumberIndex of this document within the batch (1-based). Useful for filenames or logging.
totalDocumentsNumberHow many documents were produced in this run. Same on every item.
Binary (data)BinaryThe 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?

  1. Add PDF4me to your n8n workflow. Set Resource to Generate and Generate Operations to Generate Documents (Multiple).
  2. In Credential to connect with, select your PDF4me credential or click Create New Credential and paste your API key.
  3. Set Template File Type to Word (default), HTML, or PDF.
  4. Set Output Type. PDF, Word, or Excel for Word / PDF templates; HTML only for HTML templates.
  5. 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.
  6. Set Document Data Type to JSON (default) or XML.
  7. 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.
  8. Set Output File Name to something readable like invoice so files come back as invoice_1.pdf, invoice_2.pdf, ...
  9. If outputting PDF and your template has form fields, enable Keep PDF Editable.
  10. Leave Binary Data Output Name as data unless 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).
Mail merge from a JSON array. customer letters
  1. A Google Sheets node pulls a list of customers with name, address, and balance into the workflow.
  2. A Code or Set node packages the rows into a JSON array of objects (one object per customer).
  3. 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.
  4. The node returns one item per customer named customer_letter_1.pdf, customer_letter_2.pdf, and so on.
  5. A Loop Over Items node sends each PDF to the matching customer via Gmail or uploads to Google Drive.
Template + data both as files in n8n
  1. 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.
  2. PDF4me Generate Documents (Multiple) is configured with Template File Input Type Binary Data (Template Binary Property set to the template field name) and Document Data Input Type Binary Data (Document Binary Property set to the data field name).
  3. Set Document Data File Name if the data file is not named data.json.
  4. The generated files come back as separate items and are written to a SharePoint document library named after the customer ID.
Hosted template + hosted data. invoice batch
  1. A nightly Schedule Trigger fires the invoice batch run.
  2. PDF4me Generate Documents (Multiple) is set with Template File Input Type URL (Template File URL points to the .docx invoice template on S3) and Document Data Input Type URL (Document Data File URL points to a generated billing-cycle.json file).
  3. Template File Name is invoice.docx and Document Data File Name is billing-cycle.json.
  4. Output Type is PDF, Output File Name is invoice, and Keep PDF Editable is off.
  5. Each returned item is uploaded to the customer's folder in Dropbox and emailed via Outlook.
HTML batch from pasted code → personalised landing pages
  1. A Webhook Trigger fires when a marketing campaign launches.
  2. 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.
  3. Document Data Type is JSON, Document Data Input Type is Text, and an expression maps the campaign's lead list into a JSON array.
  4. Output Type is HTML. The node returns one HTML file per lead.
  5. A Write Binary File node saves each generated HTML to a public web folder; another node sends the personalised link to each lead.
Excel output from a Word template. batch reports
  1. A daily Schedule Trigger pulls KPI numbers from PostgreSQL.
  2. A Set node groups the rows by region into a JSON array, one record per region.
  3. 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.
  4. The node returns one .xlsx per region named region_report_1.xlsx, region_report_2.xlsx, and so on.
  5. A Microsoft OneDrive node uploads each file to the matching region folder for the analytics team.

Practical Tips

Shape your data as rows
One record per output document. Single objects yield one file. defeats the purpose of this operation.
Use Generate Document (Single) for CSV / Mail Merge / Google Docs
Generate Documents (Multiple) only accepts JSON or XML data and Word / HTML / PDF templates.
"No binary data found" errors
Double-check Template Binary Property and Document Binary Property names. The Merge node from a fan-in workflow can rename binary properties.
Document Data Text is strictly required
On the Multiple operation, leaving the Text field empty rejects the node, stricter than Single.
Name outputs with a meaningful prefix
Use Output File Name like <code>invoice</code> or <code>customer_letter</code> so files are easy to scan in storage (avoid the generic <code>generated_document_*</code> default).
Plan for multiple items downstream
Use Split In Batches, Loop Over Items, or any node that handles many items. not just the first one.

Cheat Sheet

FieldValue
ResourceGenerate
OperationGenerate Documents (Multiple)
Template File TypeWord
Output TypePDF
Template File Input TypeBinary Data
Template Binary Propertydata
Document Data TypeJSON
Document Data Input TypeText
Document Data Text(bulk JSON array with multiple records)
Output File Namemy_document (optional, becomes prefix)
Binary Data Output Namedata
CredentialsPDF4me API credential

Frequently Asked Questions

How is Generate Documents (Multiple) different from Generate Document (Single)?+
Multiple renders many documents per run, one n8n item per generated document. Single produces exactly one file. Multiple supports fewer template types (Word, HTML, PDF only, no Mail Merge or Google Docs), only JSON or XML data (no CSV), and adds Excel as an output option for Word and PDF templates. Use Single for one-off documents, CSV data, Mail Merge, Google Docs, or PDF form templates.
What shape should my JSON data have?+
A JSON array where each object becomes one generated document, e.g. [{"name":"Alice","email":"[email protected]"},{"name":"Bob","email":"[email protected]"}] generates two files. The node validates that the payload parses; the API drives how many documents are produced based on the records you pass.
What does Output File Name do when many documents come back?+
It becomes a prefix. Setting Output File Name to invoice with Output Type PDF produces invoice_1.pdf, invoice_2.pdf, ... If you leave it empty, filenames come from the API or default to generated_document_1, generated_document_2, ...
Can I use CSV data with Generate Documents (Multiple)?+
No. Document Data Type only offers JSON and XML on this operation. Use Generate Document (Single) for CSV input or any other workflow that needs CSV.
How do I handle the multiple output items in n8n downstream?+
Each generated document is its own n8n item with the binary file under Binary Data Output Name (default data) and metadata fields like documentIndex and totalDocuments. Wire the node into Split In Batches, Loop Over Items, Write Binary File, or any cloud-storage / email node. they iterate over all items automatically.
Can I keep generated PDFs editable?+
Yes. Enable Keep PDF Editable when Output Type is PDF. Every generated PDF in the batch keeps its AcroForm field definitions. With Keep PDF Editable off, the form is flattened to static text on each file.
What happens if the API returns a single file instead of a list?+
You will get one n8n item only. Downstream nodes that already handle multiple items behave correctly for the single-item case. Always design the rest of the flow to handle 1..N items, not exactly N.
My data file is not named data.json. does it matter?+
When using Binary Data input, set Document Data File Name explicitly so the API treats the payload with the correct extension. Same applies to the template: use Template File Name when the binary does not carry a recognisable filename.

Same Task on Other Platforms

Get Help