Search code examples
itexthighlightinghighlight

iText Search, Highlight, image of result


I want to Do these tasks: 1-find a word in pdf 2-highlight all occurrences in that pdf, 3-save highlighted pdf as images of its pages.

How can I do this ? Any help will be appreciated.


Solution

  • com.itextpdf.text.pdf.parser.LocationTextExtractionStrategy

    It'll give you the baseline, ascent, and descent of every piece of text on the page. It's up to you to build words and rectangles from that information.

    Not Easy, but possible.

    After that, you just need to call GhostScript or PDFBox or something that can render PDFs. Hardly "the easy part", but it's a solved problem many times over.