Search code examples
javascriptsdkadobeacrobat

Adobe Acrobat Reader highlight selected text with JavaScript


How do you add an annotation to the selected text using the JavaScript API? I can't find a method that gives me the quads of the selected text so I can draw a highlight annotation around it. Any ideas?

This is what I am trying to accomplish:

var annot = this.addAnnot({
        page: 0,
        type: "Highlight",
        quads: ?????? <= this is the part I'm missing
      });

Solution

  • You can't. Reader (or Acrobat) does not expose the text selection to the JavaScript API. You'd need to write a plugin using the C++ API but then you'd also need a Reader Integration License Key which Adobe probably won't give you for this application.