I have this code that highlights the text mentioned below. I also want to be able to annotate it as well. For example, if a person hovers over the highlighted text, they should see some text, similar to comments in pdf. Is there anyway I can do that?
import fitz
doc = fitz.open("input.pdf")
page = doc[0]
#change the color of highlight, or do multiple words
text = ['highlight', 'text']
text_instances = page.searchFor(text)
text_instances = [page.searchFor(t) for t in text]
for text in text_instances:
for inst in text:
highlight = page.addHighlightAnnot(inst)
doc.save("output.pdf")
question from:
https://stackoverflow.com/questions/65853148/annotate-highlighted-text-in-pdf-python 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…