gpt4 book ai didi

python-2.7 - 如何计算python中也有空白pdf页面的pdf页面数

转载 作者:行者123 更新时间:2023-12-01 01:00:09 29 4
gpt4 key购买 nike

我尝试使用 pypdf 模块打印 pdf 文档的计数,其中包括一些空白的白色 pdf 页面。但它避免了空白页并打印剩余页数。下面是代码。

import sys

import pyPdf

from pyPdf import PdfFileReader, PdfFileWriter

pdf_document = PdfFileReader(file(normalpdfpath,"r"))

normal = pdf_document.getNumPages()
print normal

最佳答案

第1步:-

pip install pyPDF2



第2步:-
import requests, PyPDF2, io
url = 'sample.pdf'
response = requests.get(url)
with io.BytesIO(response.content) as open_pdf_file:
read_pdf = PyPDF2.PdfFileReader(open_pdf_file)
num_pages = read_pdf.getNumPages()
print(num_pages)

关于python-2.7 - 如何计算python中也有空白pdf页面的pdf页面数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16647746/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com