I am losing my mind.
This code is giving me a syntax error complaining about the second if statement. Shouldn't everything be working? I fail to see the mistake, I tried adding an else statement but that just makes that the syntax error..
Help highly appreciated!
inputpdf = PyPDF2.PdfFileReader("testfolder\\merge.pdf")
for i in range(inputpdf.numPages):
num = range(inputpdf.numPages)[-1]
if (num % 2) != 0:
print(i)
output = PyPDF2.PdfFileWriter()
output.addPage(inputpfd.getPage(range(num))
if (i % 2) == 0:
output = PyPDF2.PdfFileWriter()
output.addPage(inputpdf.getPage(i))
output.addPage(inputpdf.getPage(i+1))
with open("document-page%s.pdf" % i, "wb") as outputStream:
output.write(outputStream)
SyntaxError: '(' was never closed), which should make it easier to catch typos like this in the future.