PDF文件的分割和合并代码。文章来源地址https://www.toymoban.com/news/detail-672113.html
from PyPDF2 import PdfFileReader,PdfFileWriter
def pdf_split(filename,outputname)
pr = PdfFileReader(filename)
for page in range(p.getNumPages()):
pw = PdfFileWriter()
pw.addPage(pr.getPage(page))
with open(f'{outputname}{page}.pdf','wb') as out:
pw.write(out)
def pdf_merge(filename,outputname):
pw = PdfFileWriter()
for page in range(40):
pr = PdfFileReader(f'filename{page}.pdf')
for page in range(pr.getNumPages()):
pw.addPage(pr.getPage(page))
with open(outputname,'wb') as out:
pw.write(out)
文章来源:https://www.toymoban.com/news/detail-672113.html
到了这里,关于PDF文件分割合并的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!