How can I get the total count of total pages of a pdf using pdfminer in python

后端 未结 4 464
旧巷少年郎
旧巷少年郎 2021-02-06 17:10

In PyPDF2 pdfreader.getNumPages() gives me the total number of pages of a pdf file.

How can I get this using pdfminer?

4条回答
  •  死守一世寂寞
    2021-02-06 17:31

    Using pdfminer.six you just need to import the high level function extract_pages, convert the generator into a list and take its lenght.

    from pdfminer.high_level import extract_pages
    
    print(len(list(extract_pages(pdf_file))))
    

提交回复
热议问题