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)
question from:https://stackoverflow.com/questions/66049316/unable-to-read-a-word-from-pdf-and-highlight