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

New feature that allows inserting named-destination links doesn't work #2922

Closed
jackb007 opened this issue Dec 21, 2023 · 2 comments
Closed
Labels

Comments

@jackb007
Copy link

jackb007 commented Dec 21, 2023

Description of the bug

The xref of the link gets set to 0 even if it exists.

import fitz

def show_bug(doc):
	for index, page in enumerate(doc):
		print()
		print(index)
		links = page.get_links()

		if not links:
			continue

		link = links[0]
		print(link)
		page.delete_link(link)
		page.insert_link(link)
		links = page.get_links()
		link = links[0]
		print(link)

path = 'C:\\path\\to\\doc-with-working-named-destination-links.pdf'
doc = fitz.Document(path)
show_bug(doc)
doc.close()

How to reproduce the bug

How to reproduce the bug: run the bug-revealing script provided above on a pdf document containing named-destination links.

Sample output of the bug-revealing script:

{'kind': 4, 'xref': 2395, 'from': Rect(266.02301025390625, 387.9209899902344, 273.0050048828125, 399.0389709472656), 'name': 'nameddest=prob01.chap1.label', 'id': ''}
{'kind': 4, 'xref': 0, 'from': Rect(266.02301025390625, 387.9209899902344, 273.0050048828125, 399.0389709472656), 'name': 'nameddest=prob01.chap1.label'}

Note how the xref has disappeared. The links in the original file are working perfectly fine. An exact copy with the links deleted and immediately re-inserted contains links that don't work (due to the missing xref?).

PyMuPDF version

1.23.8

Operating system

Windows

Python version

3.9

@JorjMcKie JorjMcKie added the bug label Dec 21, 2023
JorjMcKie added a commit that referenced this issue Dec 21, 2023
The named links in list page.get_links() have no key "name" but "nameddest" instead.
When reusing an item of this list for updates we therefore must take this situation into account and fall back to "nameddest" if "name" is not present.
JorjMcKie added a commit that referenced this issue Dec 21, 2023
The named links in list page.get_links() have no key "name" but "nameddest" instead.
When reusing an item of this list for updates we therefore must take this situation into account and fall back to "nameddest" if "name" is not present.
@julian-smith-artifex-com
Copy link
Collaborator

This is fixed in release candidate 1.23.9rc1; see: #2960

@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.23.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants