You can't access selected text in JS. The closest way is by highlighting the text and then accessing that annotation.
What do you mean by accessing that annotation? The text I'm trying to access the bounds or rect of is just page text, not annotation text.
1 person found this helpful
Well, first of all it's possible to set up Acrobat so that the underlying text is automatically copied to the annotation when it's created, but even without that it's possible to find the text using the boundries of the annotation and getPageNthWordQuads.
so, are you saying that if I have text selected, I can programatically make an annotation over that text and then get the bounds of that annotation?
Is it safe to say that...
would return the rect of the third word on page 1?
No, I'm saying that if you have text annotated (with a highlight, for
example), you can find out what are the boundaries of it.
As I said earlier, JS has no way of accessing selected text or any of its
try67, I think you were stuck on my "selected text" statement. I was willing to drift from the text selection if there was a way to pinpoint a specific word and you did give me the answer I needed without realizing it. Your mention of getPageNthWordQuads was exactly what I needed. Thanks so much for your help!
You're welcome, but just be aware that this function works with 0-based
values, so this.getPageNthWordQuads(1,3) will give you the fourth word of
the second page, not the third word of the first page...
Message was edited by: try67 Oops...
lol...yeah, I found that out the hard way