Skip to content

Commit

Permalink
Fix Cimbali#219 crashes when deciphering document structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Cimbali committed Oct 30, 2021
1 parent b09b937 commit 88acc7a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pympress/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,12 @@ def get_structure(self, index_iter = None):
while True:
action = index_iter.get_action()
title = ''
page = None
try:
if action.type == Poppler.ActionType.GOTO_DEST:
title = action.goto_dest.title
if action.goto_dest.dest.type == Poppler.DestType.NAMED:
dest = self.doc.find_dest(action.goto_dest.dest.named_dest)
page = dest.page_num - 1
page = self.doc.find_dest(action.goto_dest.dest.named_dest).page_num - 1
elif action.goto_dest.dest.type == Poppler.DestType.UNKNOWN:
raise AssertionError('Unknown type of destination')
else:
Expand All @@ -806,11 +806,11 @@ def get_structure(self, index_iter = None):

# there should not be synonymous sections, correct the page here to a better guess
if page in index:
lower_bound = max(index)
lower_bound = max(index.keys())
find = index[lower_bound]
while 'children' in find:
lower_bound = max(find)
find = find[lower_bound]
lower_bound = max(find['children'].keys())
find = find['children'][lower_bound]

try:
page = min(number for number, label in enumerate(self.page_labels)
Expand Down

0 comments on commit 88acc7a

Please sign in to comment.