Link to new a different pdf in a new window #3129
-
Dear All, I've been struggling to insert a link (page.insert_link(link_dict)) that opens a different file in a new window.. I know it's possible because I have done it using Evermap software and looked at the xref data for the link: A ('xref', '67 0 R') However, I have not worked out how to do this using pymudf. The xref data looks like this instead: A ('dict', '<</S/GoToR/D[52/XYZ 0 0 0]/F<</F(example.pdf)/UF(example.pdf)/Type/Filespec>>>>') Any tips gratefully received. William Chapman |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 8 replies
-
This does it: import fitz
doc = fitz.open("input.pdf")
page = doc[0]
r = fitz.Rect(...)
link = {
"from": r,
"kind": fitz.LINK_GOTOR,
"file": path, # target path
"page": 0, # target page number
"to": fitz.Point(72, 800), # position on target page in PDF (!) coords
}
page.insert_link(link)
doc.save("output.pdf") |
Beta Was this translation helpful? Give feedback.
-
Dear Jorj,
No, it does not, unfortunately. Your code creates a link to another file,
no problem. However, when I click on the link it closes down the
originating file and opens up the new one. I want it to keep the
original file open and open a *new window.*
Is that possible?
William
…On Mon, 5 Feb 2024 at 07:03, Jorj X. McKie ***@***.***> wrote:
This does it:
import fitz
doc = fitz.open("input.pdf")page = doc[0]r = fitz.Rect(...)link = {
"from": r,
"kind": fitz.LINK_GOTOR,
"file": path, # target path
"page": 0, # target page number
"to": fitz.Point(72, 800), # position on target page in PDF (!) coords
}page.insert_link(link)doc.save("output.pdf")
—
Reply to this email directly, view it on GitHub
<#3129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AI5FHCCYQGWKVGNEV74OVEDYSB72PAVCNFSM6AAAAABCZGQFR6VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DGNRWGE3TC>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
But I think we can simply change our link-skeleton to include the |
Beta Was this translation helpful? Give feedback.
-
@chapmanwilliam or @JorjMcKie can you please provide minimal working example? |
Beta Was this translation helpful? Give feedback.
Correction. I think I have fixed it: