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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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,666 Super User 2026 Season 1 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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 474

#2
11manish Profile Picture

11manish 268

#3
David_MA Profile Picture

David_MA 243 Super User 2026 Season 1

Last 30 days Overall leaderboard