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

Categories

I am trying to read a PDF image and highlight a word in the PDF with a red box outline but the word is not getting fetched. Could someone please help me in achieving this

Here is the sample code:

import fitz
doc = fitz.open("file.pdf")
page = doc[0]
page
text = "Number"
#Number is the word to look for in the PDF
text_instances = page.searchFor(text)
#text instances returns blank values
for inst in text_instances:
    highlight = page.addHighlightAnnot(inst)
doc.save("output__.pdf", garbage=4, deflate=True, clean=True)

Here is the snip of the PDF. enter image description here

question from:https://stackoverflow.com/questions/66049316/unable-to-read-a-word-from-pdf-and-highlight

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

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...