Take a look at the javadoc for the PDFHighlighter class. As this is just an XML document, there are many ways you could create it but PDFBox does have a utility to make it easier. See the PDF Highlight File Format for more detailed documentation.īasically the document allows you to tell it the characters to highlight in the PDF by using character offsets on a page. It does this by passing an XML document to Acrobat when opening the PDF. Generate a highlight XML documentĪcrobat also allows you to tell it to highlight specific words in the PDF document.
This is a great solution because of its simplicity! It doesn’t require PDFBox at all, but it is a potential solution that many developers are not aware of. The words must be enclosed in quotes and separated by spaces for example:#search=”pdfbox rocks”