Skip to content

Commit

Permalink
Merge pull request py-pdf#2 from encolpe/patch-1
Browse files Browse the repository at this point in the history
Fix getObject on missing '/Annots'
  • Loading branch information
sfneal authored Feb 2, 2021
2 parents c2abb0f + d55405a commit ddfffe2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions PyPDF3/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1749,8 +1749,9 @@ def getObject(self, indirectReference):
else:
warnings.warn("Object %d %d not defined." % (indirectReference.idnum,
indirectReference.generation), utils.PdfReadWarning)
# if self.strict:
raise utils.PdfReadError("Could not find object.")
if self.strict:
raise utils.PdfReadError("Could not find object.")

self.cacheIndirectObject(indirectReference.generation,
indirectReference.idnum, retval)
return retval
Expand Down Expand Up @@ -2392,7 +2393,7 @@ def _mergePage(self, page2, page2transformation=None, ctm=None, expand=False):

for page in (self, page2):
if "/Annots" in page:
annots = page["/Annots"]
annots = page.get('/Annots')
if isinstance(annots, ArrayObject):
for ref in annots:
newAnnots.append(ref)
Expand Down

0 comments on commit ddfffe2

Please sign in to comment.