Count PDF Pages
Join the DZone community and get the full member experience.Join For Free
Returns the number of pages in a PDF file
import re def count_pdf_pages(path): pattern = re.compile("<<.*?Page.*?>>", re.MULTILINE) file = open(path, 'rb') content = f.read() file .close() return len(pattern.findall(content))
Opinions expressed by DZone contributors are their own.