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:
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:
@contains(triggerBody()?[‘{FilenameWithExtension}’],’.docx’)
@contains(triggerBody()?[‘{FilenameWithExtension}’],’.doc’)
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:
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
![]() |
![]() |
![]() |
![]() |
Original Post https://yaweriqbal.com/2021/05/20/convert-sharepoint-uploaded-word-file-to-pdf/