1. 把文件用Google的Chrome浏览器打开,打印其中几页,另存为PDF。简单。
2. 安装Adobe的Acrobat,里面会有更全的功能。然而,收费。
3. 用Python的PyPDF2包。(Python 3,亲测有效)
下面是Python代码实例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | pip install PyPDF2 from PyPDF2 import PdfFileWriter, PdfFileReader # 开始页 start_page = 0 # 截止页 end_page = 5 output = PdfFileWriter() pdf_file = PdfFileReader( open ( "input.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) |
联系客服