代码
import PyPDF2
out_pdf = PyPDF2.PdfFileWriter()
dst_file = f'output.pdf'
with open('input.pdf', 'rb') as src_file:
reader = PyPDF2.PdfFileReader(src_file)
pages = reader.numPages
for p in range(12): # 这里是获取源PDF前12页,保存到新PDF文件
out_pdf.addPage(reader.getPage(p))
with open(dst_file, 'ab') as out:
out_pdf.write(out)
标签:python,reader,PyPDF2,file,pdf,PDF,页码,out
From: https://www.cnblogs.com/Higgerw/p/17810412.html