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

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

4.6K

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.

Votes

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

Copy link to clipboard

Copied

Use this:

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

Votes

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
Community Expert ,
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

Votes

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