I have a project where it would be very helpful to be able to include pdf pages with certain text and or number highlighted, and in addition limit the pages output to those which have the highlighted terms.

\usepackage {fontspec} 

{phrase to be searched,word,word2,word3,another phrase, 555-222-1212}




So that the output would be the combined contents of First.pdf, Second.pdf and Third.pdf, but only the pages with the terms "phrase to be searched,word,word2,word3,another phrase, 555-222-1212" included, and with those terms background highlighted.

The closest to this I have found is automated indexing against keyword file and I upon reading it found myself unsure how one would make a complete example. There could be both an ocr and a pdf-already-with-text solution to the question. I know this is a lot to ask, but I have been surprised here before with the things that are possible with TeX.

How to highlight keywords? might be relevant to the problem.

make soul highlight span lines describes how to use the soul package to highlight text.

Or add-comments-to-pdf-files-automagically-with-regular-expressions

Looks like pdfjam could extract pages from a pdf: quickly-extracting-individual-pages-from-a-document

As an alternative: Could this be done by extracting the text from the pdf files, and then re-assembling the document? (I realize that most/all formatting would be lost)

  • Locating text or numbers withing images is called OCR (Optical Character Recognition). – John Kormylo Jan 25 '16 at 16:43
  • I guess OCR could be part of this question. – A Feldman Jan 25 '16 at 17:56
  • 3
    pdfgrep (pdfgrep.org) can tell you the page numbers for the occurences of text strings. With \write18 you could call it from your TeX file. Don't know about the highlighting. – Ethan Bolker Jan 25 '16 at 18:10
  • are you on windows? – touhami Jan 25 '16 at 21:27
  • No, I'm on debian/ubuntu using windowmaker – A Feldman Jan 25 '16 at 22:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.