web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Unanswered

Need to create a PDF from a Word template and attach it to an email using Power Automate

(4) ShareShare
ReportReport
Posted on by 17

Hi Team,

I would like to create a PDF from a Word template and attach it to an email using Power Automate. Could you please guide me on how to achieve this today?

I have already enabled entity for PDF and custom word template is ready. Not sure which API I have to use to convert to PDF without share point or one drive.

Looking forward to your support.

 

Already tried-Generate PDF from Document Templates in CDS & Dynamics 365 CE using native Web API with Flow - There's Something About Dynamics 365

I have the same question (0)
  • Suggested answer
    CU29051324-0 Profile Picture
    2 on at
    Need to create a PDF from a Word template and attach it to an email using Power Automate
    The document creation with "ExportWordDocumentToPDF" works but:
    - the API method replaces custom fonts by a small number of preinstalled fonts. There is no possibility to keep the CI of your document (unless your word template uses only these predefined fonts)
    - you can use the organization request "ExportPdfDocument" directly from a cloud flow with Http request (but the entra ID authenticated variant), but your user must be allowed to impersonate by a global admin.
    - to avoid the global admin request, it is possible to implement the "ExportPdfDocument" request inside a custom workflow activity or plugin. This works fine, but the font restriction is still there.
     
    To avoid these problems you could use a cloud flow creating a "temporary" word file on sharepoint, convert it to PDF on sharepoint and then finally upload the PDF to your dynamics record. Finally you have to delete both files on sharepoint. The disatvantages of this approach are:
    - creation of unnecessary files on sharepoint (junk files), unnecessary traffic on sharepoint. When the flow fails, the files will not be cleaned up.
    - requires usage of "use this connection" for sharepoint to make the feature available for users without sharepoint access or without access to this folder.
     
    So using the built in functionality or using Sharepoint PDF Creation have both their downsides.
  • Sushma Patole Profile Picture
    250 on at
    Need to create a PDF from a Word template and attach it to an email using Power Automate
    Use Reza's url
     
    This worked for me.
  • HR-09070029-0 Profile Picture
    16 on at
    Need to create a PDF from a Word template and attach it to an email using Power Automate
    @Daivat Vartak (v-9davar) - When I add the "perform bound action" to the table Orders. I do not see the "ExportWordDocumentToPDF" option in the list. I only see "GetSaleOrderProductsFromOpportunity" and "LockSalesOrderPricing". 

    How can I get this to work, emailing a PDF for an Order record from Power Automate?
  • SP-21031414-0 Profile Picture
    17 on at
    Need to create a PDF from a Word template and attach it to an email using Power Automate
    Hi Daivat,
     
    Thanks for your response but this action is not available to use for bound action. It simply says bound action "ExportWordDocumentToPDF" is not available for organization where as from the front end this action is available. can you please help me here if you know it.
     
  • Daivat Vartak (v-9davar) Profile Picture
    7,827 Super User 2025 Season 2 on at
    Nneed to create a PDF from a Word template and attach it to an email using Power Automate
    Hello SP-21031414-0,
     

    You're on the right track! The method you linked, using the native Dynamics 365 Web API, is indeed the most efficient way to generate a PDF from a Word template without relying on SharePoint or OneDrive for Business.

    However, there's a crucial update: The approach detailed in that article relies on the GenerateDocumentFromTemplate action, which is now deprecated.

    The Recommended Approach: Using the ExportWordDocumentToPDF Action

    Microsoft has introduced a new action, ExportWordDocumentToPDF, which is the current and recommended method for converting Word templates to PDFs directly within Power Automate.

    Here's a step-by-step guide on how to achieve this:

    1. Trigger the Flow:

    • Choose a trigger that suits your needs (e.g., "When a record is created," "When a record is updated").

    2. Get the Record:

    • Use the "Get a record" action to retrieve the record that you want to use for the Word template.

    3. Generate Word Document from Template:

    • Use the "Perform a bound action" action.

    • Entity Name: Select the entity you are working with (e.g., "Accounts," "Contacts").

    • Action Name: Select "ExportWordDocumentToPDF".

    • Item ID: Enter the record ID (e.g., from the "Get a record" action).

    • Template: Select your custom Word template.

    4. Convert Word Document to PDF:

    • Add another "Perform a bound action" action.

    • Entity Name: Select the entity you are working with (e.g., "Accounts," "Contacts").

    • Action Name: Select "ExportWordDocumentToPDF".

    • Item ID: Enter the record ID (e.g., from the "Get a record" action).

    • Word Template Data: Use the "Word Template Data" output from the previous "Generate Word Document from Template" action.

    5. Compose PDF Content:

    • Add a "Compose" action.

    • Inputs: Use the "PDF Data" output from the "ExportWordDocumentToPDF" action.

    6. Create File Attachment:

    • Add a "Create a file attachment" action.

    • Table Name: Select the entity you are attaching the PDF to (e.g., "Emails").

    • Row ID: Enter the ID of the email record.

    • File Name: Enter a file name for the PDF (e.g., "Document.pdf").

    • File Content: Use the "Outputs" from the "Compose" action.

    7. Send Email:

    • Add a "Send an email (V2)" action.
    • Configure the email with the recipient, subject, and body.
    • Attachments: Add the "File Attachment" from the "Create a file attachment" action.
     
     
    Key Points:
    • ExportWordDocumentToPDF Action: This is the crucial step. It handles the conversion from Word to PDF directly within Dynamics 365.
    • Base64 Encoding: The PDF data is returned as Base64 encoded text. You'll need to use the "Compose" action to decode it before creating the file attachment.
    • File Attachment: Use the "Create a file attachment" action to attach the PDF to an email or other relevant record.
    • Licensing: Ensure that you have the necessary Dynamics 365 and Power Automate licenses.

     

    Example Expression (Compose Action):

    base64ToString(outputs('ExportWordDocumentToPDF_2')?['body/PDFData'])

     

    Troubleshooting:

     
    • Template Issues: If the PDF is not generated correctly, check your Word template for errors.

    • Permissions: Ensure that the user running the flow has the necessary permissions to access the template and generate PDFs.

    • Error Messages: Pay close attention to any error messages returned by the actions.

    This revised approach using the ExportWordDocumentToPDF action provides a reliable and efficient way to create PDFs from Word templates in Power Automate without relying on external storage solutions.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 100 Super User 2025 Season 2

#2
Suresh Kulla Profile Picture

Suresh Kulla 72 Super User 2025 Season 2

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 59

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans