From 6399908880ce428e5af432c5c0783eae670f2f93 Mon Sep 17 00:00:00 2001 From: clach04 Date: Wed, 13 Apr 2022 20:49:45 -0700 Subject: [PATCH 1/2] Fix issues #511 - title sometimes none --- PyPDF2/pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index 0f7692bf58..d3d6650538 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -2903,7 +2903,7 @@ def getText(self, key): return retval return None - title = property(lambda self: self.getText("/Title")) + title = property(lambda self: self.getText("/Title") or self['/Title']) """Read-only property accessing the document's **title**. Returns a unicode string (``TextStringObject``) or ``None`` if the title is not specified.""" From 77e83a22749967d0253fb316847f82066407f589 Mon Sep 17 00:00:00 2001 From: clach04 Date: Thu, 14 Apr 2022 19:02:25 -0700 Subject: [PATCH 2/2] Fix #511 title sometimes None Handle case when title really is None --- PyPDF2/pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PyPDF2/pdf.py b/PyPDF2/pdf.py index d3d6650538..9d1c4ea55c 100644 --- a/PyPDF2/pdf.py +++ b/PyPDF2/pdf.py @@ -2903,7 +2903,7 @@ def getText(self, key): return retval return None - title = property(lambda self: self.getText("/Title") or self['/Title']) + title = property(lambda self: self.getText("/Title") or self.get("/Title").getObject() if self.get("/Title") else None) """Read-only property accessing the document's **title**. Returns a unicode string (``TextStringObject``) or ``None`` if the title is not specified."""