These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Detect screen size and set zoom factor .

wmcuono
Registered: Jun 2 2010
Posts: 10
Answered

Acrobat 9 Pro, Windows XP

The code below was pasted into the Document Script area. It works only when Acrobat is already opened and a file containing this code is opened using File>Open.

But if the file is double-clicked (and therefore opened) the code does not seem to execute.

Tried moving the below code to Page 1 but again it only works if Acrobat is already opened and then using File-Open to load the file.

Many Thanks.

// get object representing the primary monitor
var monitors = app.monitors.primary();

// returns an array that represents the monitor's boundaries
var res = monitors[0].rect;

// check if resolution is higher than 800x600
if(res[2] > 800 && res[3] > 600)
{
// set document zoom to 100%
this.zoom = 100;
}
else
{
// set document zoom to 65%
this.zoom = 65;
}

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Unless there is a reported error? or some other issue (have you done any debug?) I'd say you have a timing problem. Acrobat sets the zoom to some default when the document is loaded and the first page is displayed. This code may be running before Acrobat sets the default, even on the Open event on the fist page. Try putting this code into a document level fucntion, and then calling it on a delay from the Open event on page 1.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

wmcuono
Registered: Jun 2 2010
Posts: 10
""Try putting this code into a document level fucntion, and then calling it on a delay from the Open event on page 1.""

YES! The above works fine. Delays from 1 ms to several hundred ms all seem to work.

Many Thanks