Convert SharePoint Uploaded Word File to Pdf

Did you ever receive a requirement that a Word file uploaded through a model-driven app in SharePoint should be converted and saved as Pdf? I had this requirement in multiple projects. Recently I have used cloud flow to achieve this. It was a model-driven app that has integration with SharePoint for document storage. In this post, I m documenting steps.


The app has SharePoint integration enabled for the “Account” table (this post does not cover how to integrate SharePoint with Model Driven Apps, follow this link for integration details). Flow triggers when a file is uploaded from Model Driven App and created in SharePoint document library. It then uses that uploaded Word file and creates Pdf copy, and finally delete the Word version. For explaining steps, I will use the following document URL, this file was uploaded by my model-driven app:


  1. Create a cloud flow and add “When a file is created (properties only)” trigger. Configure the following properties:
    • Site Address
    • Library Name

We don’t want to trigger this flow on any file upload; rather, we want to trigger it only when a word file is created. Configure “Trigger Conditions” for word file extensions “.doc” and “docx”.

Here are expressions:


2. Initialize a string type variable “DocumentsFolderName ” to hold the subdirectory name. This is the container folder for all attachments of Model-Driven App table. Since I have configured document upload for “Account” table, its value is “account” for me. The expression in the following action will use this variable.

3. Initialize another string variable “FileNameWithPath” and use the following expression as value:

concat(replace(triggerOutputs()?[‘body/{Path}’],variables(‘DocumentsFolderName’), ”), triggerOutputs()?[‘body/{FilenameWithExtension}’])

What does this expression do?

Let’s use our example document URL, which is:

this variable will hold /test_67B9406FCBB7EB118236000D3A6A4A8A/VR.docx as value to be used in next steps.

4. Initialize string variable “NewFileNameWithExtension” and assign given expression as value:

concat(triggerOutputs()?[‘body/{Name}’], ‘.pdf’)

5. Convert Word document to Pdf, use action and do the following configs:

“Location” and “Document Library” should remain same (where Word document was uploaded). Assign “FileNameWithPath” variable as value in “File”.

6. Use SharePoint Create file action and configure as below:

  • Site Address should be same SharePoint site
  • Folder Path: assign trigger’s “Folder path”
  • File Name: use “NewFileNameWithExtension” variable
  • File Content: use output from, Convert Word Document to Pdf, previous step

7. Configure SharePoint (Delete file action) to delete original Word file

Use trigger’s Identifier in “File Identifier” field.

and that’s it, this flow will convert any word document uploaded to Pdf asynchronously.

Let’s Connect

 twIcon lnIcon fbicon

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s