Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
388 views
in Technique[技术] by (71.8m points)

Annotate highlighted text in pdf python

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...