python——提取pdf中的指定页

时间:2021-03-07 08:58:56   收藏:0   阅读:176
from PyPDF2 import PdfFileWriter, PdfFileReader
 
# 开始页
start_page = 0
 
# 截止页
end_page = 5
 
output = PdfFileWriter()
pdf_file = PdfFileReader(open("3.pdf", "rb"))
pdf_pages_len = pdf_file.getNumPages()
 
# 保存input.pdf中的1-5页到output.pdf
for i in range(start_page, end_page):
 output.addPage(pdf_file.getPage(i))
 
outputStream = open("output.pdf", "wb")
output.write(outputStream)

转发自:https://www.jb51.net/article/149587.htm

原文:https://www.cnblogs.com/shunguo/p/14493201.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!