# pdf_strip_every_other_page.py
from PyPDF4 import PdfFileReader, PdfFileWriter
number_of_pages = 500
output_writer = PdfFileWriter()
with open("/path/to/original.pdf", "rb") as inputfile:
pdfOne = PdfFileReader(inputfile)
for i in list(range(0, number_of_pages)):
if i % 2 == 0:
page = pdfOne.getPage(i)
output_writer.addPage(page)
with open("/path/to/output.pdf", "wb") as outfile:
output_writer.write(outfile)
一种方法是使用pypdf,所以在您的终端中首先要做的是
pip install pypdf4
然后创建一个与以下类似的.py脚本文件:
注意:您需要将路径更改为适合您的场景的路径
显然,这个脚本相当粗糙,可以改进,但希望与任何其他想要快速处理此场景的人共享它
相关问题 更多 >
编程相关推荐