Skip to content

Commit

Permalink
Fix #2919
Browse files Browse the repository at this point in the history
Safeguard against invalid page references.
Page deletions may have left over orphaned references in the PDF /Names dictionary.
Safeguard against non-existing pages by using method dict.get()  instead of subscripting with the xref number.
  • Loading branch information
JorjMcKie committed Dec 21, 2023
1 parent e9cb3e5 commit 36628bf
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5181,7 +5181,7 @@ def get_array(val):

# extract page number
if "0 R" in subval: # page xref given?
templ_dict["page"] = page_xrefs[int(subval.split()[0])]
templ_dict["page"] = page_xrefs.get(int(subval.split()[0]),-1)
else: # naked page number given
templ_dict["page"] = int(subval)
return templ_dict
Expand Down

0 comments on commit 36628bf

Please sign in to comment.