Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highlight text in a PDF with Python [closed]

I'm working on custom search engine for my PDF data corpus.

I have a transformation layer which is able to dump PDF content to text (using Apache Tika and GROBID). I have finished search layers and the view which return search results listing.

Now, I'd like to add highlighting feature on original PDF for the lines, where search terms was appeared. Yes, I wanna modifiy PDF files if it is necessary.

Is there any way for highlight text inside in PDF file? Are PDFMiner or PyPDF2 or other Python library is able to do that?

... or can you recommand other, maybe external service for it?

like image 263
Katharsis Avatar asked Oct 27 '16 15:10

Katharsis


People also ask

How do you highlight text in a PDF in Python?

If you want to highlight text from multiple PDF files, you can either specify the folder to the -i parameter or merge the pdf files together and run the code to come up with a single PDF that has all the text you want to be highlighted.

How do you highlight while reading a PDF?

Open your PDF in Acrobat. Click and drag the cursor to select the area of text you want to highlight. A small toolbox will appear above your text. Select the highlighter tool icon and it will automatically highlight your selected text.


1 Answers

You can highlight text using PyPDF2.

In order to find the text's location, check out this answer.

like image 162
spacevillain Avatar answered Sep 17 '22 14:09

spacevillain