0

I am using PyMuPDF from the fitz package to search and highlight words in a PDF. How to I find a word with an apostrophe in it? In my example code, text_instances will be empty. If you search for 'her' or "'", then text_instances will not be empty. Not sure what the problem is with the two strings concatenated.

Here is my example code:

import fitz

# READ IN PDF

doc = fitz.open("FILE.pdf")

page = doc[0]

text = "her's"

text_instances = page.searchFor(text)
Vishal Singh
  • 6,014
  • 2
  • 17
  • 33
bb_
  • 1
  • 1
  • Have you tested only for ' or also for ` and similar apostrophe-like characters? – mkl Jan 24 '19 at 21:32
  • @mkl great suggestion. ` is not found either on its own or in a string like her`s. – bb_ Jan 24 '19 at 22:17
  • There are other apostrophe-like unicode characters, merely not on my cellular phone keyboard. – mkl Jan 25 '19 at 07:44

0 Answers0