Press "Enter" to skip to content

Automatically convert SharePoint documents to PDF

We’re very regularly asked how to create a Flow with Power Automate to automatically documents added to a SharePoint document library 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 – https://powerautomate.microsoft.com

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 also 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 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. Within the ‘No‘ branch add a ‘Terminate‘ control action.

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 simply 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 documents to PDF format, you can obviously add further 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 created events… a common scenario could be to only convert documents where a specific SharePoint field has a specific 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!

2 Comments

  1. Adrien Verbeek Adrien Verbeek

    Hi Jay,

    I’m using this in a flow, I was wondering if it was possible to replace the word file rather than create a separate file.

    In my use case, we create a word document from a template and track changes over time using versioning functionality in SharePoint.

    I’d like to be able to override the latest word version with a pdf during the approval flow as a new document version.

    If a revision is required, then the user would restore the latest word version and modify it, then reinitiate the approval process.

    The idea is to have full traceability of the versions and not duplicate pdf vs word document

    Any suggestion to achieve this, or drection on bst practice?
    thanks in advance

    • Jay Goodison Jay Goodison

      Hi Adrien,
      Just use the SharePoint ‘Update File’ action rather than the ‘Create File’ action.
      HTH
      Jay

Leave a Reply

Your email address will not be published. Required fields are marked *