Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Adding links to PDF with JavaScript

New Here ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

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!

TOPICS
Edit and convert PDFs, How to, JavaScript

Views

62

Likes

Translate

Translate

Report

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
LEGEND ,
Jul 02, 2021 Jul 02, 2021

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 03, 2021 Jul 03, 2021

Copy link to clipboard

Copied

Use this:

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

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 04, 2021 Jul 04, 2021

Copy link to clipboard

Copied

LATEST

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

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

 

Capture_7.png

Likes

Translate

Translate

Report

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