-
Notifications
You must be signed in to change notification settings - Fork 496
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
the internal hyperlinks are broken after the merge #3868
Comments
It is mandatory to provide reproducing data when submitting a bug. |
@JorjMcKie - file1.pdf & file2.pdf have internal links and they are working as expected but after merge they are not working(merged_ouput.pdf) |
Please read the documentation here. You will see that "named" internal links are not supported / ignored. |
@JorjMcKie - I am using XSL to read data from XML and creating a ToC with internal links then converting to PDF, below is the code snippet for generating links
the generate-id() function in XSLT does not directly create a named destination link. It only generates a unique identifier for an XML node. Can you help how I can fix this internal links issue, Is there any other way to create links without using named destination? |
You can convert named links to import pymupdf
doc1 = pymupdf.open("file1.pdf")
doc2 = pymupdf.open("file2.pdf")
for page in doc2:
links = page.get_links()
for link in links: # replace NAMED by GOTO links
if link["kind"] != pymupdf.LINK_NAMED:
continue
nlink = {
"kind": pymupdf.LINK_GOTO,
"from": link["from"],
"to": link["to"],
"page": link["page"],
"zoom": link["zoom"],
}
page.delete_link(link) # delete named link
page.insert_link(nlink) # insert its GOTO version
page = doc2.reload_page(page) # important: finalize page updates!
doc1.insert_pdf(doc2)
doc1.ez_save("merged.pdf") |
@JorjMcKie - Thanks man, its working, really appreciated |
Description of the bug
I am trying to merge multiple PDFs into a single PDF using PyMuPDF, the merge works but the internal hyperlinks are broken after the merge.
How to reproduce the bug
PyMuPDF version
1.24.0
Operating system
Windows
Python version
3.8
The text was updated successfully, but these errors were encountered: