Skip to content

page.insert_link() in fitz. LINK_LAUNCH escape the ":" in the file path #3445

Discussion options

You must be logged in to vote

This script works and adds 2 working links (in relevant viewers on Windows):

import fitz

doc = fitz.open()
r1 = fitz.Rect(0, 0, 50, 50)
r2 = fitz.Rect(0, 50, 50, 100)
l1 = {
    "kind": fitz.LINK_LAUNCH,
    "from": r1,
    "file": "C:/Users/xxxxx/OneDrive/Desktop/roque.xlsx",
}
l2 = {
    "kind": fitz.LINK_URI,
    "from": r2,
    "uri": "file://C:/Users/xxxxx/OneDrive/Desktop/roque.xlsx",
}
page = doc.new_page()
page.insert_link(l1)
page.insert_link(l2)
doc.save("x.pdf")

A "page" specification makes no sense in either case! Use LINK_GOTOR if you need this.

The respective generated PDF definitions are

4 0 obj
<</Type/Page/MediaBox[0 0 595 842]/Rotate 0/Resources 3 0 R/Parent 2 0 R/Annot…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@python-and-cabbage
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by python-and-cabbage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants