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

class improves namedDest handling #3820

Closed
zhu1205 opened this issue Aug 29, 2024 · 2 comments
Closed

class improves namedDest handling #3820

zhu1205 opened this issue Aug 29, 2024 · 2 comments
Labels
enhancement fix developed release schedule to be determined

Comments

@zhu1205
Copy link

zhu1205 commented Aug 29, 2024

Is your feature request related to a problem? Please describe.
I have a pdf which contains bookmarks.
Each bookmark has a nameddest.
After call document.get_toc() I get a list of bookmarks, but there's no page in each bookmark under dest, so I step into linkDest class to find the reason.

class linkDest:
def init(self, obj, rlink, document=None):
...
if document and m:
named = m.group(1)
self.named = document.resolve_names().get(named)
if self.named is None:
# document.resolve_names() does not contain an
# entry for named so use an empty dict.
self.named = dict()
self.named['nameddest'] = named
else:
self.named = uri_to_dict(self.uri[1:])
...

I found the problem at line "self.named = document.resolve_names().get(named)" for the named is a escaped str,
named

while each key in dict returned by document.resolve_names() is a unescaped str,
esolve_name

so self.named will always be None.

Describe the solution you'd like
To solve this issue, named should be unescaped before "self.named = document.resolve_names().get(named)"

from pymupdf.mupdf import ll_fz_decode_uri_component

named = ll_fz_decode_uri_component(named)
self.named = document.resolve_names().get(named)

Describe alternatives you've considered
Are there several options for how your request could be met?

Additional context
The pdf:
21.0_TREATMENT OF ADOLESCENTS AND CHILDREN WITH CH.pdf

@zhu1205 zhu1205 changed the title cclass improves namedDest handling class improves namedDest handling Aug 29, 2024
@JorjMcKie
Copy link
Collaborator

We have developed a fix for this problem. It will be rolled out with one of the next PyMuPDF versions.

@JorjMcKie JorjMcKie added the fix developed release schedule to be determined label Aug 30, 2024
@julian-smith-artifex-com
Copy link
Collaborator

Fixed in 1.24.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement fix developed release schedule to be determined
Projects
None yet
Development

No branches or pull requests

3 participants