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 File Content straight into Create file, Send email, or any downstream action.

Related Blog Posts(3)
Generate Personalised Invitations and Merge Them Into One PDF in Power Automate: A 7-Step Dropbox Workflow
Seven-step Power Automate flow. Manual trigger, Dropbox Get file content, PDF4me Generate Documents (Multiple), Initialize variable, Apply to each plus Append to array, PDF4me Merge multiple PDFs, Dropbox Create file. One DOCX template plus a JSON array of recipients produces one consolidated PDF. Real screenshots, exact expressions, template plus JSON plus output all downloadable.
Read post →
Power Automate PDF Generation from a SharePoint List: A Handlebars Template plus HTML to PDF Invoice Workflow
Power Automate PDF generation from a SharePoint list. A Handlebars invoice template plus Convert HTML to PDF renders each row to Dropbox, no premium.
Read post →
Demand Letter Template in Power Automate: Generate a PDF Letter for Every Ready Matter in SharePoint with PDF4me
Demand letter template automation with PDF4me. Every SharePoint matter marked ready gets a PDF letter from a Word template, filed to its folder, status updated.
Read post →

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.
File Content is the dynamic-content output
The generated file appears as the File Content 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 TypeRequiredType of the template and the syntax its placeholders use. Options: Docx (PDF4me Template Syntax), Html (Handlebars Syntax), Pdf Form, Docx (Mail Merge), Google Docs. Defaults to `Docx (PDF4me Template Syntax)`.Docx (PDF4me Template Syntax)
Template File NameRequiredName of the template file, including its extension (for example `invoice-template.docx`).invoice-template.docx
Template File DataRequiredContent of the template file. Map it from the file content returned by a previous action.@{body('Get_file_content')?['$content']}
Document Data TypeRequiredFormat of the data: Json or XML. Options: Json, XML. Defaults to `Json`.Json
Document Data FileOptionalContent of a file with the data to fill the template with, in the format chosen in Document Data Type.@{body('Get_file_content')?['$content']}
Document Data TextOptionalData to fill the template with, as JSON or XML text. Required only if Document Data File is not mapped.your value
Field MetadataOptionalMetadata for fields in JSON format.your value
Output TypeRequiredFormat of the generated document. Options: PDF, Docx, Html. Defaults to `Docx`.Docx
Keep Pdf template EditableOptionalIf Yes, the form fields of a PDF template stay editable after they are filled with data. Default: No. Defaults to `No`.No

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 File Content, ready to pass into downstream Microsoft 365 actions.

FieldTypeWhat it contains
File ContentFile contentContent of the generated document. Map it into the next action, for example the File Content field of SharePoint or OneDrive Create file.
File NameTextFile name of the generated document, as returned by PDF4me. Use it as the file name when saving the file.
Page CountTextPage count reported by PDF4me for the processed document. Returned as text; wrap it in int() to use it as a number.

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 File Content 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 File Content 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 File Content dynamic-content field of the action. Pass File Content 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​