使用python拆分PDF
来源:https://www.jianshu.com/p/8d71c9cb47df
直接上代码
1 from PyPDF2 import PdfFileWriter, PdfFileReader 2 3 inputpdf = PdfFileReader(open("document.pdf", "rb")) 4 5 for i in range(inputpdf.numPages): 6 output = PdfFileWriter() 7 output.addPage(inputpdf.getPage(i)) 8 with open("document-page%s.pdf" % i, "wb") as outputStream: 9 output.write(outputStream)
需要安装PyPDF2,在命令行输入
pip install PyPDF2