Skip to main content
Known Participant
November 17, 2023
Answered

How to jump to the named destination

  • November 17, 2023
  • 2 replies
  • 3786 views

Below is the code to set the URL on the created link, using javascript in pdf.

 

var link = this.addLink(pgNum, rect);

link.setAction("this.getURL('https://www.google.com', false)");

 

I could not find the way to define Hyperlink destinations in pdf using javascript, so I created Hyperlink destinations in inDesign.

 

Now, how do I setAction on already defined Hyperlink destinations in pdf, so that when clicked on a link it will jump to that Destination.

 

What do I pass in the setAction() argument ?

 

// Specify the named destination you defined in InDesign
var namedDestination = "A1#"

 

// Set the action for the link annotation to jump to the named destination
linkAnnot.setAction("this.getURL('javascript:app.doc.gotoNamedDest(\"" + namedDestination + "\")', true);");

 
// Set the action for the link to jump to the named destination
link.setAction("this.gotoNamedDest('" + namedDestination + "');");

 

Above both options not working.

Please help.

 

This topic has been closed for replies.
Correct answer Bernd Alheit

Read this :

https://pdfobject.com/pdf/pdf_open_parameters_acro8.pdf 

2 replies

Bernd Alheit
Community Expert
Bernd AlheitCommunity ExpertCorrect answer
Community Expert
November 17, 2023
try67
Community Expert
Community Expert
November 17, 2023

Your code does not open that URL. It tries to convert it to a PDF. And that won't work outside of Acrobat. Is that what you're trying to do? If so, it's not likely this file will have any Named Destinations in it at all.

Hetal5C4CAuthor
Known Participant
November 18, 2023

++++

my requirement is,

 

in my single pdf file

I want to create hyperlink on all numbers with dot (.) (1. , 2. , etc..

 

this number will be in the starting of paragraph which should have destination with same number with # (1#, 2#, ...

 

note destination number with # can be on different page

 

++++

I could not find the way to define hyperlink named destinations in pdf using javascript, so i created hyperlink destinations in indesign.

 

now in pdf file, while creating hyperlink what do i pass in the setaction() argument ? so that it jumped to pre-defined hyperlink destinations

 

++++

below is the code i’m using

 

// specify the named destination you defined in indesig

var nameddestination = "1#"

 

// set the action for the link annotation to jump to the named destination

 

linkannot.setaction("this.geturl('javascript:app.doc.gotonameddest(\"" + nameddestination + "\")', true);"

 

OR

 

// set the action for the link to jump to the named destination

 

link.setaction("this.gotonameddest('" + nameddestination + "');"

 

above both options not working

 

please help.

try67
Community Expert
Community Expert
November 19, 2023

From Destination panel, there is an option to rename named destination.

 

Can I get all the destination s using javascript API. 


No.