With some input files my merging 2 pages into 1 page side-by-side fails. I can't find out why! Sample test code:
from PyPDF2 import PdfFileWriter, PdfFileReader
import sys
print ("2-up input " + sys.argv[1])
input1 = PdfFileReader(open(sys.argv[1], "rb"), strict=False)
output = PdfFileWriter()
lhs = input1.getPage(0)
rhs = input1.getPage(1)
lhs.mergeTranslatedPage(rhs, 420,0, True)
output.addPage(lhs)
outputStream = open(sys.argv[2], "wb")
output.write(outputStream)
outputStream.close()
The failed cases generate an output file which has ONLY the lhs page, whereas a good output has lhs and rhs pages next to each other.
A possible clue: when I run the script on a "bad" input file I get this message: "PdfReadWarning: Xref table not zero-indexed. ID numbers for objects will be corrected. [pdf.py:1503]"