如何解决使用 PyPDF2 获取页面范围
我只想从整个 pdf 文档中获取特定页面,例如从 5 到 10,怎么做?下面是我正在尝试的代码..目前它正在搜索整个文档以找到 5 位数字
import PyPDF2
from PyPDF2 import PageRange
import re
f = open('cross.pdf','rb')
pdf = PyPDF2.PdfFileReader(f)
print(pdf.numPages)
#find the phone number
pattern = r'\d{5}'
#get all the text so that you know whats the pattern of the phone numbers
all_text = ''
for n in range(pdf.numPages):
page = pdf.getPage(0)
page_text = page.extractText()
all_text = all_text + ' '+ page_text
print(all_text)`enter code here`
#check the match
for match in re.finditer(pattern,all_text):
print(match)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。