Skip to main content

Generate Document Single in Power Automate

What this action does

PDF4me Generate Document Single merges a Word, HTML, or PDF template with JSON or XML data inside a Power Automate flow and produces a personalized PDF, Word, Excel, or HTML file in one action. It replaces multi-step Microsoft 365 mail-merge flows with a single configurable step. Map the template file from any Microsoft 365 storage action (SharePoint, OneDrive, Dataverse, Outlook attachments), supply your data from dynamic content or a mapped file, and pipe the generated Doc Data straight into Create file, Send email, or any downstream action.

Related Blog Posts(1)

Authenticating Your API Request

The PDF4me Connect connector in Power Automate requires a valid connection holding your PDF4me API key. Create the connection once at flow design time, then every PDF4me action in your tenant reuses it.

Important Facts You Should Not Miss

Template File Type must match the template extension
The Template File Type dropdown (PDF4me Word Template, PDF4me HTML Template, PDF4me PDF Template) must match the file mapped under Template. A .docx file mapped with HTML selected as the type fails at run time. Word templates use mustache-style placeholders such as {{customer.name}}.
Provide either Document Data Text or Document Data File
Document Data Text accepts inline JSON or XML built from dynamic content. Document Data File accepts a binary data file from a previous Microsoft 365 step. Provide one or the other, not both, in each flow.
Doc Data is the dynamic-content output
The generated file appears as the Doc Data dynamic-content field. Pass it directly into SharePoint Create file, Outlook Send an email with attachment, OneDrive Create file, Dataverse Add a new row, or Teams Post a message with file.
PDF4me Generate Document Single action configured in a Power Automate flow with Template File Type set to PDF4me Word Template, Output Type set to PDF, and a mapped Word template from SharePoint

The Generate Document Single action in a Power Automate flow. Template File Type, Output Type, Template Name, Template, Document DataType, and Document Data Text (or Document Data File) are the fields required for a typical Word-to-PDF run.

Parameters

Required: Template File Type, Output Type, Template Name, Template, Document DataType. Conditional: Document Data Text OR Document Data File (one of the two must carry the data payload). Optional: Meta Data Json.

ParameterRequiredWhat it doesExample
Template File TypeYesFormat of the template file. PDF4me Word Template (.docx, mustache template variables, most common), PDF4me HTML Template (.html), or PDF4me PDF Template (.pdf, form field replacement).PDF4me Word Template
Output TypeYesFormat of the generated document. Word (editable .docx), PDF (locked layout, most common), Excel (.xlsx), or HTML.PDF
Template NameYesFilename of the template including extension. Map as dynamic content from the prior step File Name output (SharePoint, OneDrive, Outlook attachments).invoice_template.docx
TemplateYesBinary content of the template file. Map as dynamic content from the prior step File Content output (SharePoint Get file content, OneDrive Get file content, Outlook Get attachments).@triggerOutputs()?['body']
Document Data FileConditionalBinary data file produced by an upstream step. Use when the data lives in a file (SharePoint json file, OneDrive xml file). Required when Document Data Text is not provided.@outputs('Get_data_file')?['body']
Document DataTypeYesFormat of the data payload. Json (most common in Power Automate, maps cleanly from SharePoint columns and Forms) or Xml (for XML-native source systems).Json
Document Data TextConditionalInline data payload built from dynamic content. Use for short JSON or XML built with Power Automate expressions. Required when Document Data File is not provided.{ "Name": "John", "Age": 16, "Birth": "2000-1-1" }
Meta Data JsonNoOptional document properties as a JSON object (title, author, subject, custom fields) for templates that reference metadata at render time. Leave empty for most invoice and contract templates.{"title":"Invoice 2024-100"}

Template File Type options

PDF4me Word Template.docx with mustache placeholders
Most flexible option. Supports placeholders like {{customer.name}}, loops, conditionals, tables, and inline images. Best for invoices, contracts, certificates, and letters built in Word.
PDF4me HTML Template.html with inline CSS
Use when your team maintains email or web templates. Good for marketing PDFs and brand-styled invoices rendered from existing HTML.
PDF4me PDF TemplateFillable PDF form field replacement
Use when you have a fixed-layout fillable PDF (government, regulatory, or compliance form). The action fills named form fields with your data and returns the populated PDF.

Output Type options

PDFPrint-ready locked layout
Standard choice for invoices, contracts, certificates, and statements. Attach to an Outlook email, save to a SharePoint document library, or store in a Dataverse file column.
WordEditable .docx output
Use when recipients need to edit the document (draft contracts going back for review, HR letters requiring a manual signature line).
ExcelSpreadsheet .xlsx output
Use for data-heavy templates such as financial reports. The template must be designed in Excel.
HTMLWeb-ready HTML
Use for emails or web previews. Output is a single HTML file you can embed or send through Outlook.

Output

The action returns one bundle of dynamic content. The generated file lives on Doc Data, ready to pass into downstream Microsoft 365 actions.

FieldTypeWhat it contains
Doc DataBinaryThe generated document in the format chosen under Output Type. Pass directly into SharePoint Create file, Outlook Send an email with attachment, OneDrive Create file, Dataverse Add a new row, or Teams Post a message.
File NameStringOutput filename based on Template Name with the extension matching Output Type.

Flow examples

Common Power Automate flow patternsTypical ways to chain Generate Document Single into a flow.
SharePoint list to email PDF
  1. SharePoint When an item is created or modified trigger fires on the Invoices list.
  2. SharePoint Get file content loads the invoice Word template from the Templates library.
  3. Generate Document Single merges template with list item columns as JSON, Output Type PDF.
  4. Outlook Send an email attaches Doc Data to the customer with a thank-you body.
Forms response to certificate
  1. Microsoft Forms When a new response is submitted trigger fires for course completion.
  2. OneDrive Get file content loads the certificate Word template.
  3. Generate Document Single renders the certificate as PDF using the Forms response as JSON.
  4. SharePoint Create file stores the certificate in the Certificates document library, and Outlook Send an email delivers it to the student.
Dataverse contract to Teams approval
  1. Dataverse When a row is added to Deals trigger fires on closed-won opportunities.
  2. SharePoint Get file content loads the contract template.
  3. Generate Document Single produces the contract PDF from the deal data.
  4. Teams Post adaptive card with approval routes Doc Data to the legal owner for sign-off.

Frequently Asked Questions

What template file types does Generate Document Single accept in Power Automate?+
Three options under Template File Type: PDF4me Word Template (.docx with mustache template variables, most common), PDF4me HTML Template (.html for browser-rendered layouts), and PDF4me PDF Template (.pdf for form field replacement on a fillable PDF). Match the type to the extension of the file mapped under Template.
What output formats can the action produce?+
Output Type supports Word (.docx for editable output), PDF (locked layout, most common for invoices and contracts), Excel (.xlsx for spreadsheet output), and HTML for web embedding. The output format is independent of the template type, so a Word template can produce a PDF and vice versa.
How do I pass JSON data to the template in a flow?+
Set Document DataType to Json, then either paste the JSON object directly into Document Data Text (with dynamic content expressions for SharePoint columns or Forms responses) or map a data file from a previous step into Document Data File. Document Data Text is best for short payloads built inline, Document Data File for larger pre-built data documents.
Where does the generated file appear in dynamic content?+
The output is on the Doc Data dynamic-content field of the action. Pass Doc Data into SharePoint Create file, Outlook Send an email with attachment, OneDrive Create file, Dataverse Add a new row with file column, or Teams Post a message with file. The filename uses Template Name with the extension matching Output Type.
Does this work with Power Automate Desktop or only Power Automate (cloud)?+
The PDF4me Connect connector is a cloud connector available in Power Automate (the web flow designer). For desktop automation, call the same Generate Document Single REST endpoint with the HTTP action.
Can I generate multiple documents in a loop?+
Yes. Wrap Generate Document Single in an Apply to each loop over an array of records (Dataverse rows, SharePoint list items, Forms responses). The action runs once per record and returns one file per iteration. For true multi-record output in a single call use Generate Documents Multiple.
Is Meta Data Json required?+
No. Meta Data Json is optional. Use it when your template references document metadata (title, author, subject) at render time. Leave it empty for most invoice and contract templates.
How is this different from the Make, n8n, or Zapier version?+
All four platforms call the same PDF4me Generate Document Single backend. Power Automate is the Microsoft 365 native option with built-in SharePoint, Outlook, Teams, and Dataverse connectors. Make is the visual scenario builder, n8n is the developer-friendly self-hosted option, Zapier triggers from any of 6,000+ SaaS apps. The template logic and output formats are identical across platforms.

Same task on other platforms

Get Help