Hyperlinks -- IMPLEMENTED #807
Replies: 8 comments 4 replies
-
Annotations and widgets are automatically assigned a unique (per page) name upon creation. I have to check for links - will be added if I forgot those. |
Beta Was this translation helpful? Give feedback.
-
The annotation name is reserved for other purposes: mostly the icon name. Shouldn't be abused for private identification purposes. |
Beta Was this translation helpful? Give feedback.
-
Done. The dictionaries in |
Beta Was this translation helpful? Give feedback.
-
That's good Jorj. But I don't think it solves me problem of being able to identify links I have created, as distinguished from links that may already exist in the file. For example, I may want to be able to colour links I have created, or delete them. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
-
Wheel generation for the revised code is underway. Give half an hour time or so.
mylinks = [lnk for lnk in page.getLinks() if lnk["id"].startswith(name)]
toc = doc.get_toc(False) # important: use the full TOC
idx = n # the index of the toc entry in that list
d = toc[idx][3] # the destination dictionary of the toc entry
d["color"] = (0,0,1) # blue - always use PDF color 3-tuples!
d["bold"] = True
d["italic"] = True
d["collapse"] = False # whether to collapse/expand sub-items
doc.set_toc_item(idx, dest_dict=d] # the only valid call pattern in this case
|
Beta Was this translation helpful? Give feedback.
-
Here an example for coloring a toc item: >>> doc=fitz.open("pillow.pdf")
>>> toc=doc.get_toc(False)
>>> for i, item in enumerate(toc):
if item[:2] == [1, "Porting"]: # the item we want to color
break
>>> d = toc[i][3]
>>> d["color"] = (0,0,1)
>>> d["bold"] = True
>>> d["italic"] = True
>>> doc.set_toc_item(i,dest_dict=d)
>>> doc.save("x.pdf")
>>> Both times using Adobe Acrobat. |
Beta Was this translation helpful? Give feedback.
-
Some more on coloring TOC items:
|
Beta Was this translation helpful? Give feedback.
-
Have good news for you wrt TOC item colors: This means for yur requirement:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
It would be useful to be able to tag a hyperlink with a name string. You can do this for annotations by setting annot.info['name']="Desired Name".
In this way, I would like a) to be able to identify links created by me rather than existing links created by someone else b) so I can delete my links and not somebody else's.
Is that possible please?
William
Beta Was this translation helpful? Give feedback.
All reactions