Getting Preferences>Page Display>Resolution using Javascript

New Here ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

I have a pdf doc that when the user clicks a button, the document scales and scrolls both vertically and horizontally to a certain point inside the pdf. I need to get the user's Preference>Page Display> Resolution to ensure the user is navigated to the correct point in the pdf. How do i get that property using Javascript?

TOPICS
Acrobat SDK and JavaScript, Macintosh, Windows

Views

99

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
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Feb 26, 2019 Feb 26, 2019
While this property is not directly available, there are some things you can do to find the resolution.Here are the steps for a script to follow.1. save the current viewState:            var vsOrig = this.viewState.toSource();2. Set the zoom type to FitH.  Save the zoom level.3. Set the zoom type to FitV. Save the zoom level.4. Reset the viewSate.      this.viewState = eval(vsOrig);Now you have proportionality factors between the current zoom and the full width and height of the document. This g...

Likes

Translate

Translate
Adobe Community Professional ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

You can't access this property with Javascript.

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
community guidelines
Adobe Community Professional ,
Feb 26, 2019 Feb 26, 2019

Copy link to clipboard

Copied

LATEST

While this property is not directly available, there are some things you can do to find the resolution.

Here are the steps for a script to follow.

1. save the current viewState: 

          var vsOrig = this.viewState.toSource();

2. Set the zoom type to FitH.  Save the zoom level.

3. Set the zoom type to FitV. Save the zoom level.

4. Reset the viewSate.

     this.viewState = eval(vsOrig);

Now you have proportionality factors between the current zoom and the full width and height of the document. This gives you enough information to calculate the portion of a document page being shown so you can set the page offsets (scroll) exactly.

Its all worked out, calculations and the code, here (but it's only available to site members):

Scripts for Navigating to a specific document location

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
community guidelines