I want to insert invisible text into an existing PDF file, to make it searchable.

For instance, if the user searches for "hello", the PDF reader should send the user to the page where I embedded that text, even though it is not visible.

What Java library should I use?
I would appreciate links to specific API methods to use.

Gratis, ideally open source.

(For the curious: I want to automatically OCR incoming scanned papers and make them searchable, in an Alfresco repository, while still making only the original image visible, with the sometimes-faulty OCR result present on the same page yet invisible)

  • Would it be acceptable to store the "invisible" text in the metadata? Many document management systems will index the metadata of documents, and it would not interfere with screen readers. It would, however, be visible to a user deliberately looking at the metadata in a PDF reader (or text editor). Jan 2, 2020 at 18:36
  • @AndrewMorton: That's an idea, but it would not show the right page of the document, right? Or would it?
    – Nicolas Raoul
    Jan 3, 2020 at 2:04
  • @NicolasRaoul just being curious, what's the solution you picked? (actually I'm facing exactly the same question as you are/were ^^)
    – atticus
    Apr 4, 2021 at 20:42
  • @atticus: I ended up not implementing that feature, actually. Still interested in any solution, though.
    – Nicolas Raoul
    Apr 5, 2021 at 8:33


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.