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

Is it possible to draw linkable textboxes / text with a script?

Script Kitty
Registered: Jul 9 2010
Posts: 19
Answered

I have to link a series of technical drawings together, however, the links must be a small text-box or text below the part id. Is there a way to (once a certain part id is found) draw a box/text a certain amount of space below it and make that box or text a hyperlink?

Example before (excuse my poor ascii approximation):

___PART ID___
| |
| |
| |
| |
----> |___________|------------>

Example after:

___PART ID___
| link1 link2 |
| |
| |
| |
----> |___________|------------>

UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
the doc.addLink() method allows you to create links via scripting, but it's not trivial. In the SDK there's an example (example 2 on the addlink() page) where we look for a particular word and draw a link around it, that you can probably use as your starting point. Look at example 1 on the same page for the idea behind getting the link to do something other than opening a URL.
Script Kitty
Registered: Jul 9 2010
Posts: 19
Great, most of my problem is solved. But is it possible to draw a link a set distance from text found in a document?
UVSAR
Expert
Registered: Oct 29 2008
Posts: 1357
Yep - look at example 2 in the SDK. It finds the bounding rect* of the word and then uses it to tell the link where to appear, so you can add something to the rect's values beforehand to offset the positon.

*A rect is just a 4-value array containing [upper-left x, upper-left y, lower-right x, lower-right y] in rotated user space.
Script Kitty
Registered: Jul 9 2010
Posts: 19
Thanks for the help :)