count number of pages in pdf python pdfminer

Solutions on MaxInterview for count number of pages in pdf python pdfminer by the best coders in the world

showing results for - "count number of pages in pdf python pdfminer"
Miguel Ángel
15 Jul 2017
1from pdfminer.pdfparser import PDFParser
2from pdfminer.pdfdocument import PDFDocument
3from pdfminer.pdfpage import PDFPage
4from pdfminer.pdfinterp import resolve1
5
6file = open('some_file.pdf', 'rb')
7parser = PDFParser(file)
8document = PDFDocument(parser)
9
10# This will give you the count of pages
11print(resolve1(document.catalog['Pages'])['Count'])
12