def count_pages(input_file):
"""Count the number of pages in a file
Keyword arguments
input_file -- the full path to the input file
"""
count = 0
if is_pdf.match(input_file):
with open(input_file, 'rb') as fp:
count += len(rxcountpages.findall(fp.read()))
if count == 0:
pdf_read = PyPDF2.PdfFileReader(input_file)
count = pdf_read.getNumPages()
pdf_read = None
else:
ops = [
'identify', '-ping', '-format', "%n\\n", input_file
]
results = do_system_call(ops, return_result=True)
count = int(results.rstrip().split('\n').pop())
return count
multipage2book.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录