web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How can we get count n...
Power Automate
Unanswered

How can we get count number of pages in pdf using Power automate desktop?

(1) ShareShare
ReportReport
Posted on by 8
how can we count the number of pages in pdf using Power automate desktop
I have the same question (0)
  • Verified answer
    VishnuReddy1997 Profile Picture
    2,656 Super User 2025 Season 2 on at
    Hey Hi,
     
    Power Automate Desktop doesn't offer a direct action to count PDF pages. However, we can achieve this by using Two methods.

    1. By using Extract Tables from PDF as shown below.


    Code:
    Pdf.ExtractTablesFromPDF.ExtractTables PDFFile: $'''C:\\Users\\Desktop\\Power Automate Desktop\\Projects\\Digital Signatures\\Input Files\\9102401396.pdf''' MultiPageTables: True SetFirstRowAsHeader: True ExtractedPDFTables=> ExtractedPDFTables
    Display.ShowMessageDialog.ShowMessage Title: $'''Pages Count''' Message: ExtractedPDFTables.Count + 1 Icon: Display.Icon.None Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: False ButtonPressed=> ButtonPressed
    

    2.Python Script.
    ​​​​​​​
    Run the below Python Script using Run PowerShell script action as shown in below image.
     
     
    Python Code:
    import fitz  # PyMuPDF
    import sys
    
    def count_pages(pdf_path):
        pdf_document = fitz.open(pdf_path)
        num_pages = pdf_document.page_count
        return num_pages
    
    if __name__ == "__main__":
        if len(sys.argv) != 2:
            print("Usage: python count_pages_pymupdf.py <pdf_path>")
            sys.exit(1)
    
        pdf_path = sys.argv[1]
        num_pages = count_pages(pdf_path)
        print(f"{num_pages}")
    
     

    (Note:- if you got your solution you can mark as solution and gives kudos)

    Thanks & Regards
    Vishnu Reddy

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard