Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Open a random PDF document using Javascript

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Level 2

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;

View solution in original post

4 Replies

Avatar

Level 10

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

Avatar

Level 2

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

Level 10

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

Correct answer by
Level 2

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;