Skip to main content
csm_phil
Legend
April 1, 2021
Question

Acrobat Set new link window options

  • April 1, 2021
  • 2 replies
  • 2958 views

Hi All,

I have the requirements to set the URL links to set new window options in Acrobat. We generated the PDF from the InDesign file.

I tried the below codes, I but can set the specifier URL address, instead of the existing url address and set as the javascript options with the same address.

The beow codes works, but the "http://www.example.com/" this addres will set entire document hyperlinks url address.

 

for (var p=0; p<this.numPages; p++) {
    var box = this.getPageBox("Crop", p);
	var links = this.getLinks(p, box);
	if (links==null || links.length==0) continue;
	for (var i in links) {
        links[i].borderColor = color.blue;
        links[i].borderWidth = 2;
        links[i].setAction("this.getURL('http://www.example.com/')");
        //p.launchURL(event.target.valueAsString);
        }
    }

 



Before


Final requirement

 

thx,
csm_phil

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
April 2, 2021

In order to set a URL to open in a new browser window (which doesn't always work, by the way), you need to use this script:

app.launchURL("http://www.example.com", true);

csm_phil
csm_philAuthor
Legend
April 2, 2021

Hi,

Sorry I'm not clear can you explain in details are share your app.launchURL code to the above first post code inside.

thx,
csm_phil

try67
Community Expert
Community Expert
April 2, 2021

You need to enter that code as the parameter of the setAction command, converted to a string.

Bernd Alheit
Community Expert
Community Expert
April 1, 2021

The property "rect" of the link gives you the position of the link. With this information you can find the text at this position.

csm_phil
csm_philAuthor
Legend
April 1, 2021
quote

The property "rect" of the link gives you the position of the link. With this information you can find the text at this position.


By @Bernd Alheit

Hi Bernd,

Thanks for your reply!

My request is to set the url link address, see the above first thread, example is "Creative Common" is the text, but behind we set the url addresss is (e.g., www.google.com) I want to fetch the exisiting URL address not the text, once we get the exisiting URL address and set as the new window options.

I searched the guide, I can't get the properties to get the getLinks(), they provided the rect, border etc.,

Is this possible, could you please share your ieads.

Much welcome for your ideas!


thx,
csm_phil

Bernd Alheit
Community Expert
Community Expert
April 1, 2021

This is not possible with Javascript. It is possible when you create a plugin for Acrobat.