Skip to content

Count pages

ozaru.page_count returns the number of pages as an int.

That's useful when you need to decide what to do with a document before you process it:

import ozaru

pages = ozaru.page_count("report.pdf")

if pages > 2:
    print(f"Long document: {pages} pages")
else:
    print(f"Short document: {pages} pages")

Output:

Long document: 3 pages

Next: read page by page.