These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Text Selection into Variable, help required please...

TecNik
Registered: Feb 25 2008
Posts: 17

Hi There,

I've had a look through the JS Ref but as yet haven't found what I'm looking for.

I'm trying to get text, highlighted using the 'Select Tool', into a variable so I can search for it on a page.
Please can someone tell me if it's possible?

I've been trying to use 'app.execMenuItem("Copy");' however this doesn't feel like the best method.

If someone could point me in the right direction it would be appreciated.

Thanks in advance.

Regards,

Nick

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unfortunately this is not a simple one. Acrobat JavaScript does not provide infromation on the selection of page content. At least not directly. But I think you have a clever approach. The script could paste the clipboard text into a text field, where it could grab the text and use it in the Search Object.

But it won't work because the "Paste" menu item is restricted in Acrobat 8 and later. It cannot be called from a script.

There are some much more complex approaches, for example using the highlight annotation to do the text selection and then finding the text under the annotations rectangle.

But it's so much simpler to just ask the user to enter the text into the search window.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

TecNik
Registered: Feb 25 2008
Posts: 17
Hi Thom,

Thanks for your help with this query.
Looks like I may have to put this project on hold, or try the trickier variation.

I was trying to stay away from the user having to enter the copy to speed up a process.

Thanks again Thom, you've given me something else to have a look at.

Regards,

Nick
verTIc4L
Registered: Mar 10 2008
Posts: 2
Tell me some infos about with what Adobe Product you wanna do it.
I can easily show you a perfect example of what u wanna do in Adobe Illustrator with JavaScript :D

Cu
TecNik
Registered: Feb 25 2008
Posts: 17
Hi verTIc4L,
Thanks for your reply.
I'm trying to do it in Acrobat Pro 7, would that have a different dictionary to Illustrator?

Thanks,

Nick