In a Flow I am building I would like to obtain the number of pages in a PDF document. Is there anyway?
Solved! Go to Solution.
@nana001 You can do this in a cloud flow quite easily:
Simply get the file content of a PDF file. And then create a compose action with the following expression:
sub(length(split(replace(base64ToString(outputs('Get_file_content')?['body']['$content']), 'Type/Pages', ''), 'Type/Page')),1)
This will return you the count of pages within the PDF file.
Hi @nana001
Unfortunately using Power Automate this won't be possible to do.
Thanks
If you liked my response, please consider giving it a thumbs up
Proud to be a Flownaut!
Learn more from my blogAbm, thanks for your message.
The only other potential solution that I could find is reading the PDF file in plain text as suggested here: Solved: Re: Extracting PDF meta data and document info - Power Platform Community (microsoft.com)
However, I cannot seem to decipher the "/Pages" metadata for a PDF file. I looked through the ISO reference. Any idea how to potentially read a PDF file in plain text to get the total number of pages in it?
I found an imperfect solution for counting pdf pages in Power Automate: Here is the procedure for your reference:
1: extract your pdf file and set "the index numbers of the pages " to large quantity which is clearly pages out of bounds to make error-"Page out of bounds" happen . 😀
2: Make sure continue flow run in Advanced: Page out of bounds and set " Go to next action" only.
3: Get the last error and capture the error message, then split text by "," and get the textlist[1], Convert to number, then -2 and get the right page number now.😀
@nana001 You can do this in a cloud flow quite easily:
Simply get the file content of a PDF file. And then create a compose action with the following expression:
sub(length(split(replace(base64ToString(outputs('Get_file_content')?['body']['$content']), 'Type/Pages', ''), 'Type/Page')),1)
This will return you the count of pages within the PDF file.
It works. Thank you.
@seewo Couldn't get the proposed solution using regex running. Thanks for the imperfect alternative, which works perfectly for my need.
I like the approach of @Paulie78 , and I'm trying to use it to solve my problem as well. I need to insert a page number at the bottom of my pdfs pages.
Is there a way (without using the enconde connector) to insert the pages number (and be incremental as word does) in a pdf or a HTML file using Power Automate?
The following is my current flow (canvas app send to the flow a HTML code --> flow creates a file with the HTML ---> convert this file to pdf
Thanks
Thank you, this was a lifesaver!
For those unfamiliar, in Step 5 - Set Variable, you can expand the variable name to get 'Message.Trimmed.Trimmed' as shown below
For Step 7 - Set Variable I manually modified the variable to add "[1]" to get textlist[1]
This one is not work for some types of pdf . For ex, Pdf which was built from scan to pdf ( scan from machine) anyone has ideas ?
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
63 | |
27 | |
21 | |
15 | |
13 |
User | Count |
---|---|
123 | |
46 | |
44 | |
35 | |
31 |