📜  计算 pdf 中的页数 python pdfminer - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:33.950000             🧑  作者: Mango

代码示例1
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfpage import PDFPage
from pdfminer.pdfinterp import resolve1

file = open('some_file.pdf', 'rb')
parser = PDFParser(file)
document = PDFDocument(parser)

# This will give you the count of pages
print(resolve1(document.catalog['Pages'])['Count'])