From 4ce480fbdbdbca35b867706753a40754eda241ce Mon Sep 17 00:00:00 2001 From: Vaclav Dvorak Date: Wed, 12 May 2021 14:18:36 +0200 Subject: [PATCH] if not self.strict, ignore a /Prev entry with the value 0 in the trailer closes #530 --- PyPDF2/pdf.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index c5cae9e67..95799093e 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -1942,6 +1942,15 @@ def used_before(num, generation): else: break else: + # some PDFs have /Prev=0 in the trailer, instead of no /Prev + if startxref == 0: + if self.strict: + raise utils.PdfReadError("/Prev=0 in the trailer (try" + " opening with strict=False)") + else: + warnings.warn("/Prev=0 in the trailer - assuming there" + " is no previous xref table") + break # bad xref character at startxref. Let's see if we can find # the xref table nearby, as we've observed this error with an # off-by-one before.