python3 pdf逆序排列,pypdf2安装及使用

# 安装pypdf2,命令为 pip install pypdf2 

from PyPDF2 import PdfReader, PdfWriter

pdf_reader = PdfReader('你的路径.pdf')
pdf_writer = PdfWriter()
length = len(pdf_reader.pages)

for page in range(length-1, -1,  -1):
    pdf_writer.add_page(pdf_reader.pages[page])

with open('reordered.pdf', 'wb') as f:
    pdf_writer.write(f)

你可能感兴趣的:(python,python,pdf,开发语言)