I use PyMuPDF's
insert_link
to add links to a PDF. But when I do it, I sometimes get the warning skipping bad link / annot item 0
. When I highlight the same rect with add_highlight_annot
the area is highlighted. There is just no link. This happens to some words, but I can't find a connection between them. What does the warning mean exactly?
Bellow is the code I use:
doc = fitz.open('test.pdf')
term = "hello"
for page in doc:
rects = page.search_for(term)
for rect in rects:
page.add_highlight_annot(rect)
l = {'kind': 2, 'from': rect, 'uri': link, 'id': ''}
page.insert_link(l)