'Unable to Read Corrupted pdf using PyPDF2

I am trying to merge 2 pdfs and write to one pdf using pypdf2. Below is the code to read the file content

output = PyPDF2.PdfFileWriter()
for pdffile in self.files:
    input = PyPDF2.PdfFileReader(pdffile, strict=False)

where self.files is file objects

I am getting below error when trying to read one particular pdf file TypeError: 'NumberObject' object has no attribute 'getitem'

When i ran ghostscript on the pdf file i found that the file is corrupted and the repaired one i am able to read without errors. I wanted to check if there is any way i can read the corrupted pdf file using pypdf2 only without errors?

Thanks in Advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source