Skip to main content
ThrowBackDewd
Participant
July 2, 2021
Question

Adding links to PDF with JavaScript

  • July 2, 2021
  • 3 replies
  • 6890 views

Hello, I'm trying to add a hypertext link to my PDF using javascript (or applescript), but it's not adding quite the way I want. 

 

When I create the link rectangle, I'm applying an action with the setAction command

 

Example

myLink.setAction(\"this.getURL('http://adobe.com')\");

 

Once the link has been created, upon investigation of the link it will be created as a "Run a javascript" action in the PDF instead of an "Open a web link" action. Is there a different option instead of "getURL" that I should be using to create the link as an "Open a web link" action?

 

Thanks in advance for any assistance!

This topic has been closed for replies.

3 replies

JR Boulay
Community Expert
Community Expert
July 4, 2021

The "Hyperlink Maker" which is part of the free abracadabraTools can help you:

https://www.abracadabrapdf.net/utilitaires/utilities-in-english/abracadabratools_en/

 

Acrobate du PDF, InDesigner et Photoshopographe
try67
Community Expert
Community Expert
July 3, 2021

Use this:

myLink.setAction("app.launchURL('http://adobe.com');");

Legend
July 2, 2021

There are many types of action in PDF. But you can only add a JavaScript action with this API.  The JavaScript you are adding is this.getURL('http://adobe.com'). The effect is that it makes a JavaScript which acts as a web link. You cannot make links of any other kind programmatically.