Open a random PDF document using Javascript

Avatar

Avatar

joshuab24944986

Avatar

joshuab24944986

joshuab24944986

20-11-2015

Hello,

I am trying to create a button in my XDP form that will function as a standard "Open Page" link in a typical PDF.  I want to be able to define the file path and the page number of a PDF and open the document in a new window to that page.

The target documents are provided by a third party and I have no ability to dictate format or anything else.

Any ideas?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

joshuab24944986

Avatar

joshuab24944986

joshuab24944986

23-11-2015

I found the answer.  radzmar was partially right.  It did use app.openDoc but required a trusted function and an extra command:

var mydoc = app.openDoc(path);

mydoc.pageNum = page;

Answers (3)

Answers (3)

Avatar

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485

Avatar

radzmar

MVP

Total Posts

2.6K

Likes

386

Correct Answer

485
radzmar
MVP

23-11-2015

There's also a openDoc method available to launch locally stored files.


try {


    // Open the "other.pdf" in the same directory


    app.openDoc("./other.pdf", event.target);


    // Close this doc


    event.target.closeDoc(true);


} catch (e) {}


Avatar

Avatar

joshuab24944986

Avatar

joshuab24944986

joshuab24944986

23-11-2015

I need to open this in adobe standard NOT a web browser so the user can make edits to the target document.  LaunchURL won't work.  Is there anything like that to launch local files?

Avatar

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372

Avatar

_Bruce_Robertson

MVP

Total Posts

1.8K

Likes

268

Correct Answer

372
_Bruce_Robertson
MVP

21-11-2015

Hi,

You can specify the page number as part of the URL, so

app.launchURL("http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/js_api_reference.pdf#page=30", true)


Opens the "JavaScript for Acrobat API Reference" at page 30.

Regards

Bruce