In this guide you’ll learn how to extract a single page or multiple pages from a PDF using Power Automate. This example can also be used for other file formats by first converting a file to PDF and then extracting either a single or range of pages (see file formats we support).
Before we start building the workflow, ensure all prerequisites are in place. It is also assumed that the reader has some knowledge of building Workflows using Power Automate.
Please make sure the following prerequisites are in place:
- An Office 365 subscription with SharePoint Online license.
- Muhimbi PDF Converter for Power Automate full or free trial subscription.
- Appropriate privileges to create Flow.
- Working knowledge of MS SharePoint Online, Microsoft Power Automate.
Using Power Automate to Extract Pages from PDF Documents and Forms
On a high level, the workflow will look as follows:
- Add the ‘For a selected item‘ MS SharePoint trigger action with two mandatory inputs of type ‘Number‘. You can use this trigger to start the Flow and for the user to input the ‘Start Page‘ and ‘End Page‘ manually from the MS SharePoint Online User interface.
- Add the ‘Get file properties‘ MS SharePoint action and select the ‘Library Name‘ in which you want to Run the document extraction process and pass the ‘ID‘ value to the ‘Id‘ field.
- Add the ‘Get file content‘ SharePoint action and pass the ‘Identifier‘ which is the output of ‘Get file properties‘ action into the ‘File Identifier‘.
- Add the Muhimbi ‘Convert document’ action.
- Source file name: ‘fileName‘ the output of the ‘For a selected file‘ trigger.
- Source file content: ‘File Content‘ the output of the ‘Get File Content’ action.
- Output format: Select ‘PDF‘ from the dropdown.
- **Override settings:
Note: In the above XML, we need to pass the inputs ‘Start Page‘ and ‘End Page‘
passed by the trigger action.
- Add ‘Send an email(v2)’ action and configure it with reference to the details below:
- To: Managers email address.
- Subject: The file concat(outputs(‘Convert_document’)?[‘body/base_file_name’],’Extacted’,’.pdf’)
- Body: Email Body.
- Attachments Name – 1: concat(outputs(‘Convert_document’)?[‘body/base_file_name’],’Extacted’,’.pdf’)
- Attachments Content -1: ‘Processed File Content’ the output of ‘Convert document‘ action.
We used the ‘For a selected item’ trigger to manually start a Flow on a document. This works similarly to Flows that are automatically triggered when a file is created or changed, with one major exception, which is that by default the person starting this Flow will need to authenticate to all services used by it.
Navigate to the original library and select an item. Click the Flow dropdown and click the name of the Flow you created. It should open the blade in which you can specify the ‘Start page‘ and ‘End page‘ and then click Run Flow button.
- After a few seconds you will get an email with the Extracted Pages a PDF attachment.