Generate Document (Single) in n8n
Generate Document (Single) is an n8n node by PDF4me that merges a Word, HTML, PDF form, Mail Merge, or Google Docs template with JSON, XML, or CSV data to produce one finished document per workflow run. Use it for signed contracts, personalized letters, or on-demand reports without custom code.
What this node does
PDF4me: Generate Document (Single) merges one template with one set of data and returns one finished document per n8n run. Supports five template types (PDF4me Word Template, HTML, Pdf Form, Mail Merge, Google Docs) and three data formats (JSON, XML, CSV). Template enters via Binary Data, Base64, pasted HTML Code (HTML only), or a URL; data enters via Text, Binary Data, Base64, or URL. Ideal for single contracts, personalised letters, on-demand reports, or any one-off document. For list-driven batches use Generate Documents (Multiple).
Choose your template type
Pick the guide that matches your Template File Type in the n8n node. Each page lists the exact sample template, data files (JSON, XML, CSV), recommended field values, and a quick test workflow.
.docx with mustache placeholders. Output PDF or Word. Includes template.docx + data.json.template.pdf + formdata.json.simple_mail_merge_template.docx..docx. Output PDF or Word. Includes google-docs-template.docx.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 template-merge requests securely.
Important Facts You Should Not Miss
data). To produce many files from a list of records in one execution, use Generate Documents (Multiple) instead, or wrap this node in a loop.{{name}}) or Word merge fields must align with keys in your JSON/XML or column headers in your CSV. Mismatches render as empty values silently./generate-document-single-full-word.png)
Default Word path: Word template (binary) + JSON Text data + PDF output
/generate-document-single-full-html.png)
HTML path: pasted HTML Code + XML/JSON data + HTML output
What Parameters Does Generate Document (Single) Need?
Required in the n8n UI: Credential to connect with, Template File Type, Template File Input Type, Document Data Input Type, Document Data 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. Keep PDF Editable, Binary Data Output Name, and Template File Name (for Binary Data input) are optional with sensible defaults.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| Template File Type | Required | Format of the template. Choose PDF4me Word Template (.docx), HTML (file or pasted code), Pdf Form (PDF with form/merge fields), Mail Merge (Word mail-merge), or Google Docs (Google Docs export style). | PDF4me Word Template |
| Output Type | Required | Format of the rendered document. Word, Mail Merge, and Google Docs accept PDF or Word (default PDF). HTML accepts HTML only. Pdf Form accepts PDF only. | PDF |
| Template File Input Type | Required | How the template is supplied. Binary Data reads from a previous node (default, most common). Base64 String accepts an encoded template. HTML Code accepts pasted raw HTML (HTML template type only). 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 file. 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 with mustache placeholders like {{title}}, {{heading}}, {{content}}. Required when Template File Input Type is HTML Code (and only valid when Template File Type is 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 default like template.docx, template.html, template.pdf based on template type). Required for Base64 String, HTML Code, and URL. | template.docx |
| Document Data Input Type | Required | How the data is supplied. Text is the default (paste JSON, XML, or CSV directly). Binary Data reads a data file from a previous node. Base64 String accepts an encoded data file. URL downloads the data file from a public link. | Text |
| Document Data Type | Required | Format of the data payload. JSON for object/array, XML for XML documents, CSV for comma-separated rows. Drives both validation and the placeholder examples shown in the UI. | JSON |
| Document Data Text | Conditional | Raw JSON, XML, or CSV payload. Required when Document Data Input Type is Text. The node validates JSON parses, XML looks like XML, and CSV is non-empty. | {"name":"John Doe","email":"[email protected]"} |
| 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 Base64 Content | Conditional | Base64-encoded data file. Required when Document Data Input Type is Base64 String. | eyJuYW1lIjoiSm9obiJ9 |
| Document Data File URL | Conditional | Publicly reachable HTTPS URL to the data file. Required when Document Data Input Type is URL. | https://example.com/data.json |
| Document Data File Name | Conditional | Filename for the data file. Optional with Binary Data (falls back to data.json based on type). Required for Base64 String and URL. | data.json |
| Keep PDF Editable | Optional | Only shown when Output Type is PDF. Keeps AcroForm fields editable in the generated PDF when enabled. Default off (flattened). | Off |
| Binary Data Output Name | Optional | Name of the binary property the output item exposes. Default is data. The node sets the download filename automatically as generated_document_output.<ext>. | data |
Template File Type Options
Five template types. The choice drives which Output Type options appear and which Template File Input Types are practical. Open the matching guide above for sample files and field-by-field setup.
PDF4me Word Template.docx templates. Output PDF or Word. See guide →HTMLPdf FormMail MergeGoogle Docs.docx. Output PDF or Word. See guide →/generate-document-single-template-file-type.png)
Template File Type dropdown in the n8n node
Output Type by Template
| Template File Type | Output Type choices | Default |
|---|---|---|
| PDF4me Word Template | PDF, Word | |
| Mail Merge | PDF, Word | |
| Google Docs | PDF, Word | |
| HTML | HTML only | HTML |
| Pdf Form | PDF only |
/generate-document-single-output-type.png)
Output Type dropdown shown for Word-family templates: PDF (default) or Word
Template File Input Type Options
Pick how the template enters the node. The follow-up fields change with this choice.
/generate-document-single-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}}. 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 Input Type Options
Pick how the data enters the node.
/generate-document-single-document-data-input-type.png)
Document Data Input Type. Text, Binary Data, Base64 String, or URL
TextDefault: paste data inlineDocument Data Text. The node validates JSON parses, XML looks like XML, and CSV is non-empty. The UI shows a placeholder example matching your Document Data Type.Binary DataUse a data file from a previous nodeDocument Binary Property to the binary field name (default data). Watch that template and data binary property names do not collide when both come from the same item; use a Merge node if needed.Base64 StringBase64-encoded data file.json, .xml, or .csv file as base64 in Document Base64 Content. Document Data File Name is required so the extension matches the data type.URLDownload from a public linkDocument Data File URL to a public HTTPS URL of the JSON, XML, or CSV file. Document Data File Name is required.Document Data Type Options
Pick the format of the data payload. Drives validation and the inline placeholder example shown for Text input.
/generate-document-single-document-data-type.png)
Document Data Type. JSON, XML, or CSV (Single supports CSV; Multiple does not)
JSONDefault: object or array data{"name":"John","email":"[email protected]","items":[...]}. The node validates that the payload parses with JSON.parse.XMLXML document<?xml version="1.0"?><root><name>John</name></root>. Node checks the payload starts with < and contains >.CSVComma-separated valuesname,email\nJohn Doe,[email protected]. The node checks the payload is non-empty after trim. CSV is only available on the Single operation; Multiple does not accept CSV.Output Fields
A successful run returns one n8n item carrying 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 | Generated filename, set automatically to generated_document_output.<ext> based on Output Type (pdf, docx, html). |
mimeType | String | MIME type of the output: application/pdf, application/vnd.openxmlformats-officedocument.wordprocessingml.document, or text/html. |
fileSize | Number | Size of the generated file in bytes. |
Binary (data) | Binary | The generated document under Binary Data Output Name (default data). Pass into Write Binary File, Email, or any cloud-storage upload. |
How Do I Set Up Generate Document (Single) in n8n?
- Add PDF4me to your n8n workflow. Set Resource to Generate and Generate Operations to Generate Document (Single).
- In Credential to connect with, select your PDF4me credential or click Create New Credential and paste your API key.
- Set Template File Type to PDF4me Word Template (default), HTML, Pdf Form, Mail Merge, or Google Docs.
- Set Output Type. Word-family templates accept PDF or Word; HTML accepts HTML only; Pdf Form accepts PDF only.
- 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 Input Type to Text (default) and paste your payload into Document Data Text. or pick Binary Data, Base64 String, or URL and supply the data file.
- Set Document Data Type to JSON (default), XML, or CSV so validation and placeholders match.
- If outputting PDF and your template has form fields, toggle Keep PDF Editable as needed.
- Leave Binary Data Output Name as
dataunless a downstream node needs a different property name. Execute the node and route the single output item into Write Binary File, Email, or cloud storage.
Typical Setups
Workflow ExamplesCommon n8n workflow patterns using Generate Document (Single).
- A CRM webhook fires when a deal is marked Closed-Won.
- A Google Drive Download node pulls the standard contract template
.docx(Binary Data, propertydata). - PDF4me Generate Document (Single) runs with Template File Type PDF4me Word Template, Output Type PDF, Document Data Input Type Text.
Document Data Textis an expression that maps the deal payload into JSON. - A Sign request node forwards the generated PDF to DocuSign.
- A Schedule Trigger fires every weekday morning.
- An HTTP Request node pulls a JSON summary of yesterday's KPIs.
- PDF4me Generate Document (Single) runs with Template File Type HTML, Template File Input Type HTML Code. The HTML body is pasted in the node with
{{title}},{{heading}},{{content}}placeholders. Output Type is HTML. - A Send Email node embeds the generated HTML directly in the email body to the leadership distribution list.
- One node downloads the template; another node downloads the data file. A Merge node combines them so both binaries land on one item.
- PDF4me Generate Document (Single) runs 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 output PDF is saved to a SharePoint document library with the order ID as filename.
- A Webhook Trigger fires from an external billing system.
- PDF4me Generate Document (Single) is set with Template File Input Type URL (
Template File URLpoints to the .docx on S3) and Document Data Input Type URL (Document Data File URLpoints to a generatedcustomer.json). - Match Document Data Type to the data file extension and provide
Template File NameandDocument Data File Nameso PDF4me handles them correctly. - The output PDF is uploaded to Dropbox and emailed via Outlook.
- A typeform submission triggers the workflow.
- PDF4me Generate Document (Single) runs with Template File Type Pdf Form, Output Type PDF, Template File Input Type Binary Data (the PDF form template from Drive). Document data is the form payload as JSON Text.
- Keep PDF Editable is turned on so the recipient can correct or extend the auto-filled fields.
- The generated PDF is emailed to the applicant for review.
Practical Tips
{{name}} in the template must match "name" in JSON or the matching XML tag / CSV header. Mismatches render as empty silently.Cheat Sheet
| Field | Value |
|---|---|
| Resource | Generate |
| Operation | Generate Document (Single) |
| Template File Type | PDF4me Word Template |
| Output Type | PDF |
| Template File Input Type | Binary Data |
| Template Binary Property | data |
| Document Data Input Type | Text |
| Document Data Type | JSON |
| Document Data Text | (your inline JSON payload) |
| Binary Data Output Name | data (or generated-document) |
| Credentials | PDF4me API credential |
Frequently Asked Questions
Related Actions
Same Task on Other Platforms
POST /api/v2/GenerateDocumentSingle endpoint, for custom backend code or Postman testing.