Copy link to clipboard
Copied
I want to attach a hyperlink to the currently selected pageItem — app.selection[0].
My selected pageItem will sometimes be an image, sometimes be text.
When the user clicks on the pageItem in an interactive PDF I want it to open the URL say "adobe.com"
I can't find any resources that explains how to create hyperlinks and attach them to pageItems.
I need help. Thanks!
Thanks peeps, those two resources combined a whole bunch of trial and error was an enough to get me over the hump. (Changed my name btw)
Solution:
//Converts selected pageItem to a hyperlink
var myPageItem = app.selection[0]; //First currently selected pageItem
var myURL = "www.adobe.com"; //Pick any URL
var source = app.documents[0].hyperlinkPageItemSources.add(myPageItem);
var dest = app.documents[0].hyperlinkURLDestinations.add(myURL);
//Add hyperlink to the pageItem
app.documents[0].hyper...
Copy link to clipboard
Copied
Hello lynddonn84836010,
See this post by Manan Joshi. Seems to be excaltly what you're looking for, if not it should get you pointed in the right direction.
Regards,
Mike
Copy link to clipboard
Copied
For a full reference of what you can do with hyperlinks, see this site: http://jongware.mit.edu/idcs6js/index_Hyperlinks%20Suite.html
Specifically, the hyperlinks.add method should do what you need: http://jongware.mit.edu/idcs6js/pc_Hyperlinks.html#add
Copy link to clipboard
Copied
Thanks peeps, those two resources combined a whole bunch of trial and error was an enough to get me over the hump. (Changed my name btw)
Solution:
//Converts selected pageItem to a hyperlink
var myPageItem = app.selection[0]; //First currently selected pageItem
var myURL = "www.adobe.com"; //Pick any URL
var source = app.documents[0].hyperlinkPageItemSources.add(myPageItem);
var dest = app.documents[0].hyperlinkURLDestinations.add(myURL);
//Add hyperlink to the pageItem
app.documents[0].hyperlinks.add(source, dest, {name:myURL})
//Name can be anything you want, it can also be used to find the item with the "itemByName()" function
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more