Copy link to clipboard
Copied
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);");
Above both options not working.
Please help.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
++++
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.
Copy link to clipboard
Copied
Why doesn't you create the links in InDesign?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
A script can't handle that many pages, either. You need to use a stand-alone tool for that.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Do you see this Named Destination in the Destinations panel on the left (or wherever it is now...)?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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..
Copy link to clipboard
Copied
No, neither is possible, unfortunately.
Copy link to clipboard
Copied
From Destination panel, there is an option to rename named destination.
Can I get all the destination s using javascript API.
Copy link to clipboard
Copied
No.
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now