Unable to Open PyPDF2 Files in Adobe

Solution for Unable to Open PyPDF2 Files in Adobe
is Given Below:

When creating a PDF using the below methodology, often the PDF is unable to be opened by Adobe with the error: Error 14: Expected a dict object. Is there a workaround for this to ensure the files can be opened by Adobe? They open fine in Chrome and other readers.

p1 = PyPDF2.PdfFileReader('path/to/file.pdf')

f = open('/home/username/output.pdf','wb')
p2 = PyPDF2.PdfFileWriter()

The PdfFileMerger class works fine but doesn’t fit my use case.

More specifically, is there specific technical documentation by Adobe of what this missing dict is and what it should be?

Update comments: My guess is that when you use PdfFileReader.getPage(N) it’s losing some critical PDF elements and PyPDF does not validate the PDF to ensure the output of PdfFileWriter has those elements. For example, merging a bad PDF made by the above with a single good PDF using PdfFileMerger will result in a PDF that Adobe won’t complain about.