This post will review how to easily convert PDF to PNG with Power Automate using Encodian’s Flowr ‘Convert PDF to PNG‘ action. We will also be using the ‘Split PDF‘ action too!
The scenario for this blog is that a Marketing Manager has PDF leaflets saved to a folder in SharePoint. They want to convert each page of these leaflets into an image file to be used as content to post on social media. The images must also be saved to the correct product folder to make them easy to access. We will automate this process using Power Automate and Encodian Flowr.
The SharePoint document library has been configured as follows:
The converted images are saved in separate folders. Each leaflet is tagged with a corresponding product.
The ‘For a selected file’ trigger action triggers the Power Automate flow. This means that the user can trigger the flow directly from the selected file in the SharePoint document library.
NOTE: Although it is not best practice to create flows in the ‘Default‘ Power Automate environment, when using the ‘For a selected file’ trigger action, the flow has to be created in the ‘Default‘ Power Automate environment. If you use another environment the flow will not appear in SharePoint.
The trigger action doesn’t give us enough information about our file to get the file content straight away. We first need to use ‘Get file properties’, where we can use the file ID, and then we can use ‘Get file content’, using the file identifier.
Next, I am initialising a variable called ‘resultFolder’. This variable will hold the folder path where the converted images will be saved.
I then have a ‘Switch’ that looks at the ‘Product Value’ dynamic content (an output of the ‘Get file properties’ action). What product the leaflet is about determines what folder the images will be saved into, so for each case, I am setting the ‘resultFolder’ variable accordingly. For the default case, I am setting the folder to the ‘Marketing Leaflets’ folder.
The folder path can be set as a variable because it won’t change throughout the flow. Each image created will be about the same product because it came from the same original leaflet.
Now, we can use the first Flowr action! We will use ‘Split PDF‘ to separate all the PDF pages.
For this demo, we will be splitting the document by the number of pages with a split configuration of 1. This means that each individual page will be split. If you had a larger PDF, let’s say 10 pages, with a split configuration of 2, it would result in 5 separate documents with 2 pages each.
You can also split the document by:
You can find out more information about the ‘Split PDF’ action here:
Once the PDF has been split, we can then convert each individual page to a PNG file and save back to SharePoint. We can loop over each separated document using an ‘Apply to each’ loop with the ‘Documents’ output from the ‘Split PDF’ action.
We are using Flowr’s ‘Convert PDF to PNG‘ to do the document conversion. The ‘File Content’ and ‘Filename’ are from the current item in the loop. The ‘Filename’ output from the ‘Split PDF’ action automatically adds a number to the start of the original file name, so you don’t need to add this in yourself to make the file names unique!
I have left the other inputs as the default values, however you can change these as needed.
Once the document has been converted, the last step is to save the image to the correct folder in SharePoint using the ‘resultFolder’ variable.
To trigger the flow, click the ellipsis of the leaflet you want to convert in SharePoint, hover your mouse over ‘Automate’ and select the name of your conversion flow.
These are the results in the Flowr Images folder after the flow has run:
As we can see from the image, there are now 4 PNG files that are ready to be used across social posts.
Check out Sophie’s companion video on YouTube!
Search 150+ Actions to see how Flowr can save you time
Sign up for your free 30-day trial; no cards, catches, or contracts.
No job is too big or too small for our Professional Services team!
UPDATE: We’re excited to announce some significant updates to Flowr for Power Automate! As of October 2024, we’ve improved by updating action names and splitting Flowr’s central Power Automate connector into nine specialized connectors. These changes will make your workflow faster, smoother, and more efficient. The new action names are more precise and intuitive, saving you time, while the focused connectors enhance performance and flexibility. This update also helps future-proof the platform for even more powerful features. Check out our updated action names blog.
Technical Evangelist