Open a random PDF document using Javascript

Avatar

Avatar
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
joshuab24944986
Level 1

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
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
joshuab24944986
Level 1

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
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

397 likes

Total Posts

2,687 posts

Correct reply

492 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
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
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
joshuab24944986
Level 1

Likes

0 likes

Total Posts

6 posts

Correct reply

1 solution
Top badges earned
Validate 1
Affirm 1
View profile
joshuab24944986
Level 1

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
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_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