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

How to jump to the named destination

Participant ,
Nov 17, 2023 Nov 17, 2023

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.

 

TOPICS
How to , JavaScript , PDF
3.7K
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
1 ACCEPTED SOLUTION
Community Expert ,
Nov 17, 2023 Nov 17, 2023
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
Community Expert ,
Nov 17, 2023 Nov 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.

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
Participant ,
Nov 17, 2023 Nov 17, 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.

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
Community Expert ,
Nov 17, 2023 Nov 17, 2023

Why doesn't you create the links in InDesign?

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
Participant ,
Nov 18, 2023 Nov 18, 2023

We have almost 8K-10K pages in single pdf, which can not be handled in InDesign CS6.

 

For small pdf already did linking in InDesign.

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
Community Expert ,
Nov 18, 2023 Nov 18, 2023

A script can't handle that many pages, either. You need to use a stand-alone tool for that.

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
Participant ,
Nov 18, 2023 Nov 18, 2023

Thanks @try67 ,

 

Could you please help with this.

 

++++

below is the code i’m using

 

// specify the named destination you defined in indesign

var nameddestination = "1#"

 

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

 

link.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

 

Is it possible in pdf to jump to named destination.

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
Community Expert ,
Nov 18, 2023 Nov 18, 2023

For starters you need to use the correct spelling of the methods you're using.

It's setAction, not setaction. And gotoNamedDest, not gotonameddest. And getURL, not geturl. etc.

 

Once you've done that run the code and let us know what the output is. Are there any error messages in the Console? etc.

 

I still don't think this is the code that will do what you described, though.

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
Participant ,
Nov 18, 2023 Nov 18, 2023

script.PNG

Please find the attached code from pdf.

 

When clicking on link this.pageNum and this.getURL works, but somehow this.gotoNamedDest doesn't work. 😞

 

'A3#' I have defined in InDesign as a Text Anchor.

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
Community Expert ,
Nov 18, 2023 Nov 18, 2023

Do you see this Named Destination in the Destinations panel on the left (or wherever it is now...)?

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
Participant ,
Nov 18, 2023 Nov 18, 2023

In pdf, where do I check..?

I'm using Adobe Acrobat Pro.

 

In InDesign, yes it is showing as Text Anchor from which I generated this PDF.

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
Community Expert ,
Nov 18, 2023 Nov 18, 2023

That's the thing, a Text Anchor and a Named Destination are not necessarily the same thing.

In Acrobat you need to look for the Destinations panel. It used to appear on the left-hand side, next to Pages and Bookmarks, like this:

 

try67_0-1700313307604.png

 

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
Participant ,
Nov 18, 2023 Nov 18, 2023

gotoNamedDest() works now.

 

Text Anchor name was changed in pdf, and not same as defined in InDesign.

 

Many Thanks . 

I really appreciate your support.

Thank you so much.

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
Participant ,
Nov 18, 2023 Nov 18, 2023

One more thing to know:)

 

Is there any way to get all the named destination s and can rename it using javascript.?.. as  naming standard s are same. As pdf appended InDesign file name along with original text Anchor name that I have to remove..

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
Community Expert ,
Nov 18, 2023 Nov 18, 2023

No, neither is possible, unfortunately.

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
Participant ,
Nov 18, 2023 Nov 18, 2023

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

 

Can I get all the destination s using javascript API. 

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
Community Expert ,
Nov 19, 2023 Nov 19, 2023
LATEST

No.

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
Community Expert ,
Nov 17, 2023 Nov 17, 2023
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