我正在尝试在 python 中制作一些程序来操作我的 pdf beamer 演示文稿。教授使用点击动态转换,所以一页有几个点击转换。我想打印这些演示文稿,但我有大约 5000 页。所以我只想使用最后一次点击转换页面,所以我会将页面数量减少到 500 左右。我正在使用 PyPDF2 模块,但它不能生成有效的 pdf 文件。这是代码:
from pyPdf import PdfFileWriter, PdfFileReader
import os,sys
pdful = raw_input("Uneti ime fajla:")
output = PdfFileWriter()
input1 = PdfFileReader(open(pdful, "rb"))
m = []
f = True
print ("Uneti strane koje zelite da zadrzite.String 0 kraj unosa:\n")
while f:
l = int(raw_input("Uneti broj stranice:"))
if l == 0:
f = not f
else: m.append(l-1)
for i in range(len(m)):
strana = input1.getPage(int(m[i]))
output.addPage(strana)
outputStream = file("Mat8.pdf","wb")
output.write(outputStream)
# string writings are in Serbian, but that's not so important. Program should take input from user: name of file to manipulate, and pages that should copy.