Search code examples
javascriptacrobatselectedtext

Get selected text with Acrobat Javascript API


I'm trying to make a plugin written in javascript in Acrobat Pro XI.

I digged pretty much in the documentation, but founds nothing that helps me doing this simple thing.

Is there a way to get the selected text in an open document?


Solution

  • Your findings are correct. (Acrobat) JavaScript has no access to "selected text" in the base document.

    A possible workaround is using the Highlight annotation. You either set the option to show the selected text in the popup box, and then you can access it directly from JavaScript.

    …Or you read out the coordinates of the annotation, loop through the words of the page, compare with the coordinates and if you have a match, you have the "selected" text.