You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I merge two PDF files with reproducer code provided, I get merged.pdf files with some links not working anymore.
To reproduce a bug, download basic-link-1.pdf and attachment-sample-1.pdf files and run provided script in a directory that contain them. Open produced merged.pdf.
Expected result:
merged pdf has all links working
Observed result:
links "Linking to an ID" and "Linking to a page number (page 2) and setting the display ratio (200%)" do not work in merged.pdf.
Checked in Mac OS Preview and Chromium PDF viewers.
import fitz
out = fitz.open()
for file in "basic-link-1.pdf", "attachment-sample-1.pdf":
out.insert_pdf(fitz.open(file))
out.save(filename="merged.pdf")
PyMuPDF version
1.24.1
Operating system
MacOS
Python version
3.12
The text was updated successfully, but these errors were encountered:
File 'basic-link-1.pdf' contains a names dictionary (structure in the PDF catalog). Document-wide information like the names dictionary is not copied to the target PDF in method .insert_pdf() because this is a page-based method.
Named links in the source dictionary can thus not be copied - there is no internal link-kind-conversion like LINK_NAMED ==> LINK_GOTO. So "Linking to an ID" is bound to fail.
So the remaining issue is the incorrect handling of the zoom value.
I therefore are taking the liberty to change the issue title accordingly.
JorjMcKie
changed the title
Merged PDF files have broken links
Incorrect handling of the link zoom parameter in link insertions
Apr 6, 2024
You can walk through the named links of a page. Their dictionary items should contain all information you need to turn them into LINK_GOTO items. That one named items is
Description of the bug
When I merge two PDF files with reproducer code provided, I get
merged.pdf
files with some links not working anymore.To reproduce a bug, download
basic-link-1.pdf
andattachment-sample-1.pdf
files and run provided script in a directory that contain them. Open producedmerged.pdf
.Expected result:
Observed result:
Checked in Mac OS Preview and Chromium PDF viewers.
basic-link-1.pdf
attachment-sample-1.pdf
merged.pdf
How to reproduce the bug
PyMuPDF version
1.24.1
Operating system
MacOS
Python version
3.12
The text was updated successfully, but these errors were encountered: