Sunday, April 18, 2021

#1 2021-03-24 01:51:45 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 200

InDesign - Cross References, Hyperlinks, Bookmarks scriptable?

Hi, has anyone ever worked with navigation stuff in InDesign, such as hyperlinks,bookmarks, and cross references?

When I have a document ready for print, I would like to make some internal navigation links so that when I make a PDF, users can jump to text elsewhere in the document.

For example, I construct a Table of Contents from scratch using the paragraph style of the major headings. I would like to make the ToC item clickable so that it jumps to that heading in the document.

So, I would like to know if something like this is Applescriptable:1) Make the destination text into a destination, and 2) make some other text clickable to jump to that destination. I will know all the headings in advance.

I don't think it's possible to include such things in Adobe Tagged Text (which is how the bulk of the document is created).

Any pointers or articles/discussions/reference material is appreciated, thanks!

Offline

 

#2 2021-03-25 05:15:51 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6615

Re: InDesign - Cross References, Hyperlinks, Bookmarks scriptable?

This should get you started:

Applescript:

tell application "Adobe InDesign 2021"
   tell document 1
       set sourceRef to object reference of word 1 of text frame 1 of page 1
       set destRef to object reference of word -1 of text frame 1 of page -1
       set theDest to make hyperlink text destination with properties {destination text:destRef, label:"Some label"}
       set theSource to make hyperlink text source with properties {source text:sourceRef, name:"Some name"}
       make hyperlink with properties {source:theSource, destination:theDest, visible:true, highlight:invert, width:thick, border color:dark green, border style:dashed, name:"Link name"}
   end tell
end tell


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2021-03-25 03:40:04 pm

kerflooey
Member
Registered: 2011-07-07
Posts: 200

Re: InDesign - Cross References, Hyperlinks, Bookmarks scriptable?

Thanks, Shane! It is a good start. I have multiple words in some ToC entries, and there are linefeeds among the paragraphs, so it's pretty finicky getting the sourceRefs cleaned up and just right. Somewhat confusing!

It looks like I will need to know the obj refs of the ToC entry text in the body of the doc in order set the destRef. I think I can gather that info in a separate process, and once I have parallel lists to match sourceRefs and destRefs I will be able to finish it.

BTW, when I refer to, say, paragraph 47 of the contents of the text frame, it doesn't give me the whole paragraph if it contains a linefeed. Is there a solution to getting the whole paragraph with the linefeed? Thanks again! -k

Last edited by kerflooey (2021-03-25 04:26:47 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)