for Microsoft Power Automate and Azure logic apps

By Jay Goodison

24th March 2022

Convert a PDF file to images with Power Automate

We’ve been working really hard over the past few months adding performance optimizations and 10+ new actions to the Encodian connector. At the time of writing these new actions are now available on Encodian’s (Azure PaaS hosted) global cloud platform, and Microsoft are updating Power Automate to make these new actions available to all regions; this is due to complete sometime April 22. Over the coming weeks we’ll be releasing new blog posts providing guidance and examples for using these new actions.

Firstly, we’re really pleased to introduce two new actions which enable the conversion of a PDF file into either an array of images (one image per page) or a single multi-page TIFF:

Convert a PDF file to an array of images

The ‘Convert PDF to Images‘ action accepts a single PDF file and returns an array of images pertaining to the configuration supplied. Each page within the PDF document will be converted to a single image, which is why a collection (array) of images files is returned. Let’s set up a really simple flow showcasing how to use this action; for this example we’ll setup a flow to automatically perform the conversion when a PDF document is added to a specific folder.

1. Create a new ‘Automated cloud flow

1.a. Flow name: Provide a name for your flow

1.b. Trigger: Select the ‘When a file is created in a folder‘ SharePoint trigger action

1.c. Click ‘Create

2. Configure the ‘When a file is created in a folder‘ SharePoint trigger action as required.

3. To ensure the flow is only triggered when a PDF document is added we need to add a trigger condition to the ‘When a file is created in a folder‘ SharePoint trigger action. We’ll add this trigger condition: @endswith(triggerOutputs()?[‘headers/x-ms-file-name’], ‘pdf’)

Reference: Create Power Automate Trigger Conditions Simplified

4. Add the Encodian Convert PDF to Images action

4.a. File Content: Select the ‘File Content‘ property provided by the ‘When a file is created in a folder‘ SharePoint trigger action

4.b. Image Format: Select the required image format

4.c Filename Prefix: Optional – Add a filename prefix for the filename value of the image files generated. I have used the following expression which essentially takes the source filename and removes the file extension: replace(triggerOutputs()?[‘headers/x-ms-file-name’],’.pdf’,”)

5. Add the SharePoint ‘Create File‘ action

5.a. Site Address: Set as per the trigger actions value or the target site which will store the image files

5.b. Folder Path: Select the folder

5.c. File Name: Select the ‘Documents Filename‘ property provided by the Encodian Convert PDF to Images action

NOTE: Power Automate will automatically create an ‘Apply to each‘ loop and place the ‘Create file‘ action inside because the Encodian action is returning an array.

5.d. File Content: Select the ‘Documents File Content‘ property provided by the Encodian Convert PDF to Images action

The flow is now complete and should follow this construct:

You can now test your flow and validate that the PDF document added to the target SharePoint library has been converted into an array of images:

and post flow execution:

Convert a PDF file to a TIFF file

The ‘Convert PDF to TIFF‘ action accepts a single PDF file and returns a single TIFF file pertaining to the configuration supplied. Let’s setup a really simple flow showcasing how to use this action; for this example we’ll set up a flow to automatically perform the conversion when a PDF document is added to a specific folder.

1. Follow steps 1 > 3 in the ‘Convert a PDF file to an array of images‘ section of this post

2. Add the Encodian ‘Convert PDF to TIFF‘ action

2.a. File Content: Select the ‘File Content‘ property provided by the ‘When a file is created in a folder‘ SharePoint trigger action

2.b. Filename: Either select a dynamic property (the file extension will automatically change to TIFF) or manually enter a filename

5. Add the SharePoint ‘Create File‘ action

5.a. Site Address: Set as per the trigger actions value or the target site which will store the image files

5.b. Folder Path: Select the folder

5.c. File Name: Select the ‘Filename‘ property provided by the Encodian ‘Convert PDF to TIFF‘ action

5.d. File Content: Select the ‘File Content‘ property provided by the Encodian ‘Convert PDF to TIFF‘ action

The flow is now complete and should follow this construct:

You can now test your flow and validate that the PDF document added to the target SharePoint library has been converted into a TIFF file:

and post flow execution:

Final thoughts…

Hopefully, this post provides a few good examples of how you can utilise the new Encodian Convert PDF to Images and Convert PDF to TIFF actions within Power Automate to automatically convert PDF files to image file formats.

We hope you’ve found this guide useful. As ever please share any feedback or comments, all welcome!

Leave a comment

Your email address will not be published.