How can I open linked external PDF in existing window (javascript)??

Nov 15, 2017

Copy link to clipboard

Copied

Hi, all.

This is my 2nd day fiddling with java script and I would appreciate any help.

Here is what I want to do...

  Add links on each page which opens an external PDF file in existing window

Here is the code

-----------------------------

var linkWidth = 36, linkHeight = 18;

//get target PDF name

var myname = this.documentFileName;

    myname = myname.slice(0,1);

var my_target_pdf = myname + " Section illustration.pdf";

//do it all pages

for ( var i=0; i < this.numPages; i++)

{

var cropBox = this.getPageBox("Crop", i);

var offsetLink = cropBox[2] - cropBox[0] - linkWidth;

var linkRect2 = [602,linkHeight+550,linkWidth + offsetLink-32,550];

var rhLink = this.addLink(i, linkRect2);

app.openInPlace = true;

rhLink.setAction("app.openDoc('" + my_target_pdf + "', this);" );

}

--------------------------------------

It links to the external PDF, however it opens new window.

Also my customer does not want to see security alert when the external PDF opens.

So I don think I can use launchURL...

Any help is really appreciated.

Thank you!

TOPICS
Acrobat SDK and JavaScript, Windows

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

How can I open linked external PDF in existing window (javascript)??

Nov 15, 2017

Copy link to clipboard

Copied

Hi, all.

This is my 2nd day fiddling with java script and I would appreciate any help.

Here is what I want to do...

  Add links on each page which opens an external PDF file in existing window

Here is the code

-----------------------------

var linkWidth = 36, linkHeight = 18;

//get target PDF name

var myname = this.documentFileName;

    myname = myname.slice(0,1);

var my_target_pdf = myname + " Section illustration.pdf";

//do it all pages

for ( var i=0; i < this.numPages; i++)

{

var cropBox = this.getPageBox("Crop", i);

var offsetLink = cropBox[2] - cropBox[0] - linkWidth;

var linkRect2 = [602,linkHeight+550,linkWidth + offsetLink-32,550];

var rhLink = this.addLink(i, linkRect2);

app.openInPlace = true;

rhLink.setAction("app.openDoc('" + my_target_pdf + "', this);" );

}

--------------------------------------

It links to the external PDF, however it opens new window.

Also my customer does not want to see security alert when the external PDF opens.

So I don think I can use launchURL...

Any help is really appreciated.

Thank you!

TOPICS
Acrobat SDK and JavaScript, Windows

Views

63

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
Nov 15, 2017 0

Have something to add?

Join the conversation