Skip to content

Commit

Permalink
BUG: Fix missing page for bookmark
Browse files Browse the repository at this point in the history
Closes #968
  • Loading branch information
MartinThoma committed Jun 21, 2022
1 parent 4c9fd44 commit 66e886a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions PyPDF2/_merger.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,6 @@ def add_bookmark(
"""
if self.output is None:
raise RuntimeError(ERR_CLOSED_WRITER)
out_pages = cast(Dict[str, Any], self.output.get_object(self.output._pages))
if len(out_pages["/Kids"]) > 0:
page_ref = out_pages["/Kids"][pagenum]
else:
page_ref = out_pages

action = DictionaryObject()
zoom_args: ZoomArgsType = []
Expand All @@ -673,8 +668,9 @@ def add_bookmark(
zoom_args.append(NumberObject(a))
else:
zoom_args.append(NullObject())
dest = Destination(
NameObject("/" + title + " bookmark"), page_ref, NameObject(fit), *zoom_args

dest = Bookmark(
TextStringObject(title), NumberObject(pagenum), NameObject(fit), *zoom_args
)
dest_array = dest.dest_array
action.update(
Expand Down

0 comments on commit 66e886a

Please sign in to comment.