Я читаю текст и разбиваю его на куски. Итак, для приведенного ниже текстового снимка экрана на одной из страниц исходного PDF-файла я получаю текст, прочитанный следующим образом:

Текст, который у меня есть на Python:
Код: Выделить всё
text_variable = cancer. Your team should include the following \nboard-certified experts:\n \n� A pulmonologist is a doctor who’s an \nexpert of lung diseases.\n \n� A thoracic radiologist is a doctor who’s \nan expert of imaging of the chest
Теперь мне нужно найти приведенный выше текст на странице PDF, а затем выделить эти строки с помощью аннотации в PyMUPDF. Я попробовал ниже:
Код: Выделить всё
doc = fitz.open("/Users/abc.pdf") # open a document
page = doc.load_page(13)
#print(page.get_text())
text_variable = "cancer. Your team should include the following \nboard-certified experts:\n \n� A pulmonologist is a doctor who’s an \nexpert of lung diseases.\n \n� A thoracic radiologist is a doctor who’s \nan expert of imaging of the chest"
quads = page.search_for(text_variable, quads=True)
#Add a highlight annotation for each rectangle
page.add_highlight_annot(quads)
Как мне заставить это работать?>
Подробнее здесь: https://stackoverflow.com/questions/765 ... ng-pymupdf
Мобильная версия