Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Invalid Link #2450

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion pypdf/_writer.py
Expand Up @@ -2129,9 +2129,12 @@ def add_annotation(
# destination
if to_add.get("/Subtype") == "/Link" and "/Dest" in to_add:
tmp = cast(Dict[Any, Any], to_add[NameObject("/Dest")])
# Changes target_page_index an integer to target_page an IndirectObject
pages_obj = cast(Dict[str, Any], self.get_object(self._pages))
target_page = pages_obj[PA.KIDS][tmp["target_page_index"]]
dest = Destination(
NameObject("/LinkName"),
tmp["target_page_index"],
target_page,
Fit(
fit_type=tmp["fit"], fit_args=dict(tmp)["fit_args"]
), # I have no clue why this dict-hack is necessary
Expand Down