Skip to main content
MarkWalsh
Inspiring
June 23, 2017
Answered

Initial page in Open Options

  • June 23, 2017
  • 2 replies
  • 1409 views

Is there a way, via javascript, to determine (and change) the initial page that is set in the Open Options for a document?

I have a script which does a lot of processing of PDF files, and if the initial page is not set to the first page in the open options, I would like to alert the user, and give the option of changing it if needed.

This topic has been closed for replies.
Correct answer Joel Geraci

You can't change the initial page setting in the PDF via JavaScript. However, you can detect what page the PDF is on when it opens and then alert the user if it's not the first page and allow them to override it. At that point you have a few choices. If you want the PDF to always override the initial view settings, then you'd add a hidden field to the document and store the user selection there. If you want the override to be user specific, then you'd store the selection in the global object.

Your script would look for the setting. If not found, give the user the option to "change" it. If it is found, jump to the first page.

If either of those sounds reasonable, I can provide further help.

2 replies

try67
Community Expert
Community Expert
June 23, 2017

No, JS has no access to this information.

Joel Geraci
Community Expert
Joel GeraciCommunity ExpertCorrect answer
Community Expert
June 23, 2017

You can't change the initial page setting in the PDF via JavaScript. However, you can detect what page the PDF is on when it opens and then alert the user if it's not the first page and allow them to override it. At that point you have a few choices. If you want the PDF to always override the initial view settings, then you'd add a hidden field to the document and store the user selection there. If you want the override to be user specific, then you'd store the selection in the global object.

Your script would look for the setting. If not found, give the user the option to "change" it. If it is found, jump to the first page.

If either of those sounds reasonable, I can provide further help.

MarkWalsh
MarkWalshAuthor
Inspiring
June 23, 2017

Thanks, I was afraid of that.

I'm not looking for a script to add within the document, just wanted to be able to let the user know if this document wasn't set to open to page 1. This script resides in an action that is run to do some final checks and processing on these documents to finalize them before they are distributed. Usually, they should be set to the first page, but if it's not, I'd like the user to know so they can determine if there is a reason for this, or it needs to be changed.

Thanks for the info.

Joel Geraci
Community Expert
Community Expert
June 23, 2017

Ok - in that case, I'd create an Acrobat Action something like the "Prepare for Distribution" that uses the action "Document Processing" -> "Set Open Options" first and then "More Tools" -> "Execute JavaScript" for the rest of your checks. Actions can chain processing steps. If the document was set to either the default or already set to page 1, the open options don't really change anything so it doesn't matter what the original setting was.