diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index 25c8339cc..d0c2f2636 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -1062,7 +1062,11 @@ def _flatten(self, pages=None, inherit=None, indirectRef=None): self.flattenedPages = [] catalog = self.trailer["/Root"].getObject() pages = catalog["/Pages"].getObject() - t = pages["/Type"] + + t = "/Pages" + if "/Type" in pages: + t = pages["/Type"] + if t == "/Pages": for attr in inheritablePageAttributes: if attr in pages: