diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index 547284f80..1d0e95011 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -1575,9 +1575,11 @@ def _flatten(self, pages=None, inherit=None, indirectRef=None): if inherit is None: inherit = dict() if pages is None: - self.flattenedPages = [] + # Fix issue 327: set flattenedPages attribute only for + # decrypted file catalog = self.trailer["/Root"].getObject() pages = catalog["/Pages"].getObject() + self.flattenedPages = [] t = "/Pages" if "/Type" in pages: