pdf中提取某一页

from PyPDF2 import PdfWriter, PdfReader

# 开始页
start_page = 0
# 截止页
end_page = 2


output = PdfWriter()
pdf_file = PdfReader(open("a.pdf", "rb"))
pdf_pages_len = len(pdf_file.pages)


for i in range(start_page, end_page):
    output.add_page(pdf_file.pages[i])

outputStream = open("b.pdf", "wb")
output.write(outputStream)

你可能感兴趣的:(pdf,python)