Generate Document (Single) is a PDF4me action for Power Automate that merges one data record into a Word template and returns a finished PDF. This walkthrough builds a five-step flow: two Dropbox fetches for the invoice data and the .docx template, PDF - Generate Document (Single) to merge them, and Create file to write the result. For invoices it handles the hard part, which is not the header fields but the line items: a table that has to grow to however many rows the data holds.
1. Manually trigger a flow → 2. Dropbox, Get file content using path for the invoice data → 3. a second Dropbox fetch, renamed Get Invoice Template, for the .docx → 4. PDF, Generate Document (Single) with Template File Type Docx (PDF4me Template Syntax), Document Data Type Json and Keep Pdf template Editable No → 5. Dropbox, Create file with File Content from the generate step.
Plain Docx does simple field substitution: one placeholder, one value. Pick plain Docx for an invoice and the line item table will render once, with the first record, and silently drop the rest. It is the most common thing to get wrong here and the output looks plausible, which is what makes it dangerous. Docx (PDF4me Template Syntax) understands the repeating constructs, which is how a single template row becomes nineteen rows when the data holds nineteen line items.
What you are automating
Invoice templates look simple until you notice the table in the middle. Name and address are one value each. The line items are three rows this time and nineteen next time, and the totals underneath have to land in the right place either way. That repeating section is why invoices are built from templates rather than assembled by hand in a flow. Generate Document (Single) merges one data record into the template and returns the finished PDF, repeating section included.
At a glance
- Manually trigger a flow
- Get file content using path (Dropbox) for the invoice data
- Get Invoice Template (Dropbox) for the
.docx - PDF - Generate Document (Single) (PDF4me)
- Create file (Dropbox)

Five steps, and the whole thing ran in about 4 seconds.
Why this pattern works
Finance adds a VAT line, legal rewords the payment terms, marketing updates the logo. With the layout in a .docx in storage, those people edit a Word document, which they can already do. With the layout built inside the flow, every wording change becomes a Power Automate ticket.
Template File Type on Docx (PDF4me Template Syntax) handles the repeating row, so the table grows to as many rows as the data holds.
In production the data usually comes from the system that raised the invoice rather than from a file. Replace the first fetch with a query against your accounting system or database and everything downstream is unchanged.
What you need
- The PDF4me PDF connector in your Power Automate environment.
- A storage connection. This flow uses Dropbox.
- Two files: an invoice
.docxtemplate, and a.jsonfile with the invoice data.
Build the flow
Step 1: Manually trigger a flow
Add Manually trigger a flow.
Step 2: Get file content using path (Dropbox)
Flow so far: trigger only.
- Add Dropbox: Get file content using path.
- File path: the JSON holding the invoice — customer, dates, line items, totals.

Step 3: Get Invoice Template (Dropbox)
Flow so far: trigger, the data fetch.
- Add a second Dropbox: Get file content using path and rename it Get Invoice Template.
- File path: the Word template.

Step 4: Generate Document (Single) (PDF4me)
Flow so far: trigger, both fetch steps.
- Add PDF: Generate Document (Single).
- Set the five mappings below.
| Field | Value here | Notes |
|---|---|---|
| Template File Type | Docx (PDF4me Template Syntax) | Enables the repeating-row syntax |
| Template File Name | New_invoice_template.docx | |
| Template File Data | from the template step | |
| Document Data Type | Json | |
| Document Data File | from the data step |

- Output Type:
PDF. Keep Pdf template Editable:Noflattens the result. An invoice somebody can edit after you send it is not an invoice.

The table syntax is documented in the Word template tables guide.
Step 5: Create file (Dropbox)
Flow so far: trigger, both fetches, Generate Document (Single).
- Add Dropbox: Create file.
- Set the output folder.
- File Name: name it from the invoice number rather than the template. The field takes a dynamic expression, so pull the number out of the data you already have in the flow.
- File Content: from the generate step.

Quick reference
| # | Action | Main mapping |
|---|---|---|
| 1 | Manually trigger a flow | |
| 2 | Get file content using path | File path: the invoice .json |
| 3 | Get Invoice Template | File path: the invoice .docx |
| 4 | Generate Document (Single) | Template File Type Docx (PDF4me Template Syntax), Document Data Type Json, template and data from steps 3 and 2 |
| 5 | Create file | Output folder, File Name from the invoice number, File Content from step 4 |
Troubleshooting
Template File Type is plain Docx. Switch it to Docx (PDF4me Template Syntax).
The names in the template do not match the keys in the JSON, and they are case sensitive.
Build File Name from the invoice number in the data.
What to try next
Generate Documents (Multiple) takes many records and returns one PDF each.
The placeholder syntax overview.
The repeating-row construct behind the invoice table.
The documentation for the action.
FAQ
How do I generate an invoice PDF in Power Automate?
Add the PDF4me Generate Document (Single) action, map a Word template and a JSON data file, set Template File Type to Docx (PDF4me Template Syntax), and write the result with Create file.
How do I handle a variable number of line items?
Use the PDF4me template syntax rather than plain Docx, and build the table with the repeating row construct. The template holds one row; the output gets as many as the data has.
Can the data come from a database instead of a file?
Yes. Replace the first fetch step with whatever queries your system and pass the result to Document Data Text instead of Document Data File.
Can I generate many invoices at once?
Yes, with Generate Documents (Multiple), which takes many records and returns one PDF each.
The template belongs to finance. The flow just fills it in.
