Generate Document Single in Power Automate
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.
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
{{customer.name}}.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..webp)
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.
| Parameter | Required | What it does | Example |
|---|---|---|---|
| Template File Type | Yes | Format 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 Type | Yes | Format of the generated document. Word (editable .docx), PDF (locked layout, most common), Excel (.xlsx), or HTML. | PDF |
| Template Name | Yes | Filename of the template including extension. Map as dynamic content from the prior step File Name output (SharePoint, OneDrive, Outlook attachments). | invoice_template.docx |
| Template | Yes | Binary 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 File | Conditional | Binary 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 DataType | Yes | Format 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 Text | Conditional | Inline 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 Json | No | Optional 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{{customer.name}}, loops, conditionals, tables, and inline images. Best for invoices, contracts, certificates, and letters built in Word.PDF4me HTML Template.html with inline CSSPDF4me PDF TemplateFillable PDF form field replacementOutput Type options
PDFPrint-ready locked layoutWordEditable .docx outputExcelSpreadsheet .xlsx outputHTMLWeb-ready HTMLOutput
The action returns one bundle of dynamic content. The generated file lives on Doc Data, ready to pass into downstream Microsoft 365 actions.
| Field | Type | What it contains |
|---|---|---|
Doc Data | Binary | The 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 Name | String | Output 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 When an item is created or modified trigger fires on the Invoices list.
- SharePoint Get file content loads the invoice Word template from the Templates library.
- Generate Document Single merges template with list item columns as JSON, Output Type PDF.
- Outlook Send an email attaches Doc Data to the customer with a thank-you body.
- Microsoft Forms When a new response is submitted trigger fires for course completion.
- OneDrive Get file content loads the certificate Word template.
- Generate Document Single renders the certificate as PDF using the Forms response as JSON.
- SharePoint Create file stores the certificate in the Certificates document library, and Outlook Send an email delivers it to the student.
- Dataverse When a row is added to Deals trigger fires on closed-won opportunities.
- SharePoint Get file content loads the contract template.
- Generate Document Single produces the contract PDF from the deal data.
- Teams Post adaptive card with approval routes Doc Data to the legal owner for sign-off.