私はpdfビーマーのプレゼンテーションを操作するためにPythonでいくつかのプログラムを作ろうとしています。教授はクリックダイナミックトランジションを使用するので、1ページにはいくつかのクリックトランジションがあります。私はこれらのプレゼンテーションを印刷したいが、私は約5000ページを持っている。だから私はちょうど最後のクリックトランジションページを使用したいので、私は約500ページの数を最小限に抑えます。私はPyPDF2モジュールを使用していますが、それは有効なPDFファイルを作成しません。ここでは、コードです:PyPDFモジュールは有効な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.
代わりに 'open'機能を使用し、ファイルを開くために' file'を使用しないでください。また、 'outputStream.close()'を最後に置いて書き込みが完了したことを確認するために、出力ファイルを閉じたいと思うかもしれません。 – Bakuriu