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!
This should get you started:
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
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