Automatically convert SharePoint documents to PDF

November 29th 2019

We’re regularly asked how to create a Flow with Power Automate to automatically convert SharePoint documents to PDF format whilst avoiding a recursive event…. so we thought it was about time we document how to do it!

1. Launch Power Automate

2. Create a new ‘Automated flow.

3. Provide the following information:

3.a. Flow name: Enter a relevant name/description for the Flow

3.b. Select the SharePoint ‘When a file is created (properties only)‘ trigger action

NOTE:

This will convert documents to PDF format when they are added to SharePoint. To convert PDF when documents are modified, select the SharePoint ‘When a file is created or modified (properties only)‘ trigger action.

3.c Click ‘Create.

4. Configure the trigger action:

4.a. Site Address: Set to the target SharePoint site

4.b Library Name: Set to the target SharePoint library

4.c Folder Path: (Optional) Set to the target SharePoint library/folder or leave blank to target an entire SharePoint library

5. Add a ‘Condition‘ action and configure it as follows:

5.a Value: Select the ‘File name with extension‘ property from the SharePoint ‘When a file is created (properties only)‘ trigger action

5.b. Operator: Select the ‘does not end with‘ operator

5.c. Value: Enter ‘pdf

NOTE:

This condition will ensure that the Flow only attempts to convert documents which aren’t already PDF documents. Thus when this Flow adds the newly converted PDF document, event recursion will be prevented!

6. Add a ‘Terminate’ control action within the’ No’ branch.

6.a Status: Select ‘Succeeded.

7. Within the ‘Yes‘ branch, add a SharePoint ‘Get File Content‘ action.

7.a. Site Address: Set as per the value configured in step 4.a

7.b. File Identifier: Select the ‘Identifier’ property from the SharePoint ‘When a file is created (properties only)’ trigger action

8. Add the Encodian ‘Convert to PDF‘ action

8.a. Filename: Select the ‘File name with extension‘ property from the SharePoint ‘When a file is created (properties only)‘ trigger action

8.b. File Content: Select the ‘File Content‘ property from the SharePoint ‘Get file content‘ action

8.c. PDF Filename: Select the ‘File name with extension‘ property from the SharePoint ‘When a file is created (properties only)‘ trigger action

NOTE:

The Encodian action will automatically change the file extension to ‘.pdf’ for any value provided in the ‘PDF Filename‘ field, allowing you to enter the current filename value.

9. Add a SharePoint ‘Create file‘ action

9.a. Site Address: Set as per the value configured in step 4.a

9.b Folder Path: Set to the target location for the new PDF document.

9.c. File Name: Select the ‘Filename‘ property from the Encodian ‘Convert to PDF‘ action

9.d. File Content: Select the ‘File Content‘ property from the Encodian ‘Convert to PDF‘ action

10. The Flow configuration is now complete and should follow this construct:

11. Let’s test the Flow. Click ‘Test

12. Click ‘Save & Test

13. Now, add a document to the target document library. I’ve added a Microsoft Visio document.

The converted PDF document has been added to the SharePoint library:

Finally…

This post shows a super simple Flow for automatically converting SharePoint documents to PDF. You can add additional conditions to meet your finite requirements and optionally utilise the SharePoint ‘When a file is created or modified (properties only)‘ trigger action to handle document change as well as created events… a common scenario could be to only convert documents where a specific SharePoint field has a particular value, i.e. Document Status = ‘Approved.’

We hope you’ve found this guide useful, and as ever, please share any feedback or comments – all are welcome!

Author
Jay Goodison

Managing Director

You might also be interested in...