Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hyperlink InDesign Script Javascript

New Here ,
Mar 26, 2020 Mar 26, 2020

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!

TOPICS
Scripting
5.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Mar 27, 2020 Mar 27, 2020

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
...
Translate
Advisor ,
Mar 26, 2020 Mar 26, 2020

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.

 

https://community.adobe.com/t5/indesign/how-to-convert-text-selection-into-hyperlink/td-p/10442568?p...

 

Regards,

Mike

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 27, 2020 Mar 27, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 27, 2020 Mar 27, 2020
LATEST

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

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines