Skip to main content
tofutim
Participant
April 8, 2020
Question

text under mouseover

  • April 8, 2020
  • 2 replies
  • 358 views

Is there an efficient way of getting the word under the mouse using the Acrobat SDK? I have seen some discussion of using AVPageViewDevicePointToPage, enumerating the text elements, then doing a hit test using PDEElementIsAtPoint. Of course, this is probably not so efficient.  Any tips much appreciated. I would like to make a simple dictionary lookup tool that responds as you move the mouse.

This topic has been closed for replies.

2 replies

Legend
April 9, 2020

Another way is to create a word finder for the current page. You can go though the list of words and compare quads to see which word is at a point. This is preferable to using PDEElement since a word may be many elements. To optimise you need only make the word finder once per page, and you can experiment with alogorithms to make optimised indexes to the quad list. 

Thom Parker
Community Expert
Community Expert
April 9, 2020

I've wrote exactly that code almost 20 years ago. It don't think I'd call it efficient. It was a pain to write, but it's more than fast enough to walk the page content looking for words.  Its much easier to use the wordfinder since the code doesn't have to push into xObjects and compensate for the local content matrix. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often