Fotolia

Publishing with Silicon

Silicon Publishing blog: reconciling information and rendition technologies
  • Home
  • About
Home > InDesign > Scripting Hyperlinks in InDesign

Scripting Hyperlinks in InDesign

November 23rd, 2009 admin Leave a comment Go to comments

I was asked how to script hyperlinks in InDesign, based on someone who dug up this old article that I wrote many years back, when I still used VBA for InDesign. Well, nowadays I only use JavaScript when scripting, but hopefully this basic example will help:

var myDocument = app.documents.item(0);
with(myDocument.pages.item(0)){
//Get a reference to the text frame.
var myTextFrame = textFrames.item(0);
var myParagraph = myTextFrame.paragraphs.item(0);
myHyperlinkURL = myDocument.hyperlinkURLDestinations.add("http://www.publishingsilicon.com");
myHyperlinkSource = myDocument.hyperlinkTextSources.add(myParagraph);
myHyperlink = myDocument.hyperlinks.add(myHyperlinkSource,myHyperlinkURL);
myHyperlink.visible=false;
}

This assumes a text frame exists with some text in it, and that when you export the PDF you either check Include\hyperlinks in the PDF Export dialogue, or do the equivalent with code if exporting programmatically.

I need to get around to updating that data-generated example some day. Amazing how many people around the world seem to stumble upon it.

Categories: InDesign Tags: Hyperlinks, InDesign
Comments (0) Trackbacks (0) Leave a comment Trackback
  1. No comments yet.
  1. No trackbacks yet.
Subscribe to comments feed
 
InDesign Scripting with VBA Example The Two Perspectives on XML
RSS
  • Google
  • Youdao
  • Xian Guo
  • Zhua Xia
  • My Yahoo!
  • newsgator
  • Bloglines
  • iNezha

Max Dunn's twitter

  • 16 Free InDesign Scripts now available on our Resources page: http://t.co/Be7xJmfr 12:21:09 AM May 14, 2012 from LinkedIn ReplyRetweetFavorite
  • Silicon Publishing invents the desperationCounter http://t.co/b22IwUvY http://t.co/Ml3cSmJc 06:14:52 PM May 09, 2012 from LinkedIn ReplyRetweetFavorite
  • We are really going to PePcon! http://t.co/Kph26SAN 04:55:57 PM May 09, 2012 from LinkedIn ReplyRetweetFavorite
  • InDesign Server automation is the core of our expertise. Beautiful technology. http://t.co/CRetctsv 07:44:48 AM May 07, 2012 from LinkedIn ReplyRetweetFavorite
  • It amuses me that the Financial Times re-spams the same iPad hype they did a year back, and it is taken as news, again http://t.co/v4IsPVkL 06:39:35 AM May 03, 2012 from web ReplyRetweetFavorite
  • RT @talljim0155: What book publishers should learn from Harry Potter http://t.co/5RJrL3Sm 08:19:09 PM March 31, 2012 from Tweet Button ReplyRetweetFavorite
  • Our plugin makes it to Australia - http://t.co/G466gUyq 05:21:22 AM March 20, 2012 from LinkedIn ReplyRetweetFavorite
  • Our plugin is finally available in Germany - http://t.co/EhJwm0aq 06:42:26 PM March 17, 2012 from LinkedIn ReplyRetweetFavorite
  • Very cool that this is available free online. http://t.co/kjoG92cy 11:52:15 PM March 16, 2012 from LinkedIn ReplyRetweetFavorite
@maxdunn

Categories

  • Adobe
  • Apple
  • Creative Suite
  • Day Software
  • DITA
  • Esko
  • Flash
  • General
  • HTML5
  • InDesign
  • Kindle
  • MarkLogic
  • Scene7
  • Tablet
  • Web App
  • Web to Print
  • XML

Blogroll

  • A List Apart
  • DITA-FMx
  • IDML
  • InDesign Server
  • Silicon Publishing

Archives

  • May 2012
  • March 2012
  • February 2012
  • November 2011
  • October 2011
  • August 2011
  • June 2011
  • April 2011
  • December 2010
  • November 2010
  • October 2010
  • June 2010
  • May 2010
  • February 2010
  • December 2009
  • November 2009

Meta

  • Log in
Top WordPress
Copyright © 2009-2012 Publishing with Silicon
Theme by NeoEase. Valid XHTML 1.1 and CSS 3.