Skip to main content

Google Docs

What this guide covers

This guide walks you through merging a Google Docs exported .docx template in n8n using google-docs-template.docx and google-docs-data.json. The template uses mustache placeholders ({{name}}, {{course}}, etc.). Data is a JSON array with one object per row. For Generate Document (Single), use one object in the array. Output can be PDF or Word.

Before You Start

Exported Google Docs template
Design your template in Google Docs, then download as Microsoft Word (.docx). The sample google-docs-template.docx is a course certificate with {{name}}, {{course}}, {{date}}, and {{instructor}}.
JSON array data
Use google-docs-data.json (recommended), test.xml, or test.csv. Like Mail Merge, Google Docs data is an array of objects. For one certificate, paste an array with a single object.
PDF4me credential in n8n
Create a PDF4me credential in n8n and paste your API key. The same key works across all PDF4me nodes in your instance.
Google Docs vs other Word template types

Google Docs is for .docx files exported from Google Docs with mustache {{field}} placeholders. PDF4me Word Template uses <<[fieldName]>> LINQ syntax. Mail Merge uses classic Word MERGEFIELD codes. Pick the type that matches how your template was built.

Sample File Pack

Download all four files below. One exported Google Docs template plus three equivalent data formats.

What's Inside the Sample Files

Placeholders in google-docs-template.docx

The sample is a course completion certificate with four mustache merge fields:

Mustache placeholderCertificate label in templateSample value (google-docs-data.json)
{{name}}Participant nameAlice Johnson
{{course}}Course titleIntro to Automation
{{date}}Completion date2026-03-10
{{instructor}}Instructor nameMr. Smith
Mustache syntax (Google Docs export)

Type placeholders directly in Google Docs as plain text, for example {{name}}. After export to .docx, PDF4me replaces each tag with the matching JSON key. This is the same mustache style as HTML templates, but the file format is Word, not HTML.

Field mapping across all data files

PlaceholderJSON key (google-docs-data.json)XML element (test.xml)CSV column (test.csv)Sample value
{{name}}namenamenameAlice Johnson
{{course}}coursecoursecourseIntro to Automation
{{date}}datedatedate2026-03-10
{{instructor}}instructorinstructorinstructorMr. Smith

Unlike PDF4me Word Template, there are no <<[field]>> tags. Unlike Mail Merge, there are no MERGEFIELD codes. Keys in your JSON array objects map to {{field}} placeholders one to one.

The Workflow at a Glance

Manual Trigger → Read Binary File (google-docs-template.docx) → PDF4me Generate Document (Single) → (optional) Write Binary File
Stepn8n nodePurpose
1Manual TriggerStart the workflow on demand
2Read Binary FileLoads google-docs-template.docx into binary property data
3PDF4me → Generate Document (Single)Merges template + JSON array, outputs PDF or Word
4Write Binary File or Send Email (optional)Saves or sends generated_document_output.pdf
Template File Type dropdown in n8n PDF4me Generate Document (Single) node showing Google Docs among Word, HTML, Pdf Form, and Mail Merge options

Set Template File Type to Google Docs. Choose PDF or Word for Output Type.


Step 1: Download and Place the Sample Files

  1. Download google-docs-template.docx and google-docs-data.json from the Sample File Pack above.
  2. Save the template somewhere n8n can read it (local path on self-hosted, or cloud storage for production triggers).
  3. Optionally download test.xml or test.csv to test other data types.

To use your own Google Doc: open it in Google Docs, choose File → Download → Microsoft Word (.docx), and use that file as your template.


Step 2: Create the n8n Workflow

  1. In n8n, create a new workflow.
  2. Add a Manual Trigger node.
  3. Add a Read Binary File node after the trigger.
  4. Add PDF4me → Generate Document (Single) after Read Binary File.
  5. Connect your PDF4me credential.
HTML Code is not valid here

Template File Input Type: HTML Code only works when Template File Type is HTML. For Google Docs, use Binary Data, Base64 String, or URL.


Step 3: Load the Template (Read Binary File)

Configure the Read Binary File node:

FieldValue
File PathFull path to your downloaded google-docs-template.docx
Property Namedata (default; used as Template Binary Property in PDF4me)

Execute this node once and confirm the output item shows binary data with filename google-docs-template.docx.


Step 4: Configure PDF4me Generate Document (Single)

Core settings

FieldValueNotes
Credential to connect withYour PDF4me credentialGet API key
ResourceGenerate
Generate OperationsGenerate Document (Single)
Template File TypeGoogle DocsExported Google Docs .docx with mustache tags
Output TypePDF or WordPDF for sharing; Word if the recipient should edit the merged document

Template input (from Read Binary File)

FieldValue
Template File Input TypeBinary Data
Template Binary Propertydata
Template File Namegoogle-docs-template.docx

Document data (paste JSON array from google-docs-data.json)

FieldValue
Document Data Input TypeText
Document Data TypeJSON
Document Data TextPaste the full contents of google-docs-data.json (see block below)
[
{
"name": "Alice Johnson",
"course": "Intro to Automation",
"date": "2026-03-10",
"instructor": "Mr. Smith"
}
]
JSON must be an array

Google Docs template data is a JSON array, even for a single certificate. One object in the array produces one merged document with Generate Document (Single).

Output options

FieldValue
Keep PDF EditableOff (default) when Output Type is PDF
Binary Data Output Namedata (default)

Step 5: Execute and Verify the Output

  1. Click Execute workflow.
  2. Open the PDF4me node output. Under Binary, open property data (generated_document_output.pdf or .docx).
  3. Confirm all four placeholders are filled:
    • name → Alice Johnson
    • course → Intro to Automation
    • date → 2026-03-10
    • instructor → Mr. Smith

If a field is blank, compare your JSON keys with the mustache tags in the exported .docx character by character.


Step 6: Save or Send the Output (Optional)

Write Binary File:

FieldValue
File Namecertificate-output.pdf
Data Property Namedata
Output PathTarget folder on your n8n host

Send Email: attach the binary data from PDF4me as the PDF or Word attachment.


Alternative Data Formats

Option A: JSON file as binary (google-docs-data.json)

  1. Add Read Binary File for google-docs-data.json (use a Merge node if template and data share the workflow item).
  2. Set Document Data Input Type to Binary Data, Document Data Type to JSON, Document Binary Property to your data field, Document Data File Name to google-docs-data.json.
Binary property name collision

If both template and data use property data, one overwrites the other. Use separate names (e.g. template and rowData) or merge items from two Read Binary File nodes.

Option B: XML (test.xml)

Set Document Data Type to XML and paste one record (the sample file contains two; use the first for a single run):

<?xml version="1.0" encoding="UTF-8"?>
<Records>
<Record>
<name>Alice Johnson</name>
<course>Intro to Automation</course>
<date>2026-03-10</date>
<instructor>Mr. Smith</instructor>
</Record>
</Records>

Element names match the mustache keys and JSON properties.

Option C: CSV (test.csv)

Set Document Data Type to CSV and paste (header row + one data row):

name,course,date,instructor
"Alice Johnson","Intro to Automation","2026-03-10","Mr. Smith"

Column headers match the mustache placeholder names directly.


Alternative Template Input: URL

Host google-docs-template.docx at a public HTTPS URL, then set:

FieldValue
Template File Input TypeURL
Template File URLPublic link to google-docs-template.docx
Template File Namegoogle-docs-template.docx

No Read Binary File node is required. Data can still be pasted as Document Data Text or loaded from a URL.


Production Workflow Patterns

Common ways to generate from Google Docs templates in productionOnce the sample test works, replace the Manual Trigger with these patterns.
Google Sheets row to certificate
  1. Sheets trigger on new completion row.
  2. Code node wraps the row in a JSON array: [{"name": "...", "course": "...", ...}].
  3. PDF4me Google Docs with fixed google-docs-template.docx from binary or URL.
  4. Email the merged PDF to the participant.
Dropbox folder trigger
  1. New JSON file lands in a watched folder.
  2. Load the fixed Google Docs template from the same folder or a URL.
  3. Pass file contents as Document Data (Binary Data or Text).
  4. Upload output PDF to an Output folder. See the Zapier trigger blog for a similar pattern.
Bulk certificates (many rows)
  1. Export participants as a JSON array (one object per person).
  2. Switch to Generate Documents (Multiple) for one PDF per row.
  3. Keep Generate Document (Single) when you only need one merged file per run.

Frequently Asked Questions

How is Google Docs different from PDF4me Word Template?+
Google Docs templates are .docx files exported from Google Docs with mustache {{field}} placeholders. PDF4me Word Template uses <<[fieldName]>> LINQ syntax in a native Word .docx. Both accept PDF or Word output, but the placeholder syntax and Template File Type differ.
Do I upload the Google Doc directly?+
No. Export the Google Doc as Microsoft Word (.docx) first, then load that file in n8n as Binary Data or via URL. PDF4me reads the exported .docx, not a live Google Docs link.
Why must JSON be an array?+
Google Docs template data follows the same array pattern as Mail Merge. Generate Document (Single) uses the first row when you pass one object. Generate Documents (Multiple) processes every row and returns multiple output files.
Why is a placeholder blank?+
JSON keys must match mustache tag names exactly, including case. name works; Name or full_name usually does not. Open the exported .docx in Word and search for {{ to list every tag.
PDF or Word output?+
Choose PDF for emailing, archiving, or printing certificates. Choose Word when the recipient needs to edit the merged document after generation.