Tips & Tricks

Finding user screen resolution with JavaScript

January 12, 2005

Advertisement
Advertisement
 

PDF's cross-platform nature makes it very portable, but it also means that there is a multitude of different software environments, preference settings and hardware configurations to be found in the potential audience of any widely distributed document. For this reason, it can be really useful to run some JavaScript that checks these things and modifies the behavior of the PDF accordingly.

This is a piece of code that I find particularly useful for consumer or customer documentation -- basically, it checks the user's screen resolution. This information can then be used in a number of ways, but one would be setting a document's initial zoom level based on the user's screen resolution (e.g. If the screen resolution is 800x600 or below, set the document zoom to 65%, but if the screen resolution is above 800x600, set the zoom level to 100%.)

Run this code at document open using document level JavaScript (more on document level JavaScript here.)

// 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;
}
Related Products at PDF Store

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

ARTS PDF Crackerjack

Impose pages, automate your workflow, verify certified PDFs, print accurate colour separations, conv... View full product details
Download free demo

PDF Download

PDF Download removes the pain of dealing with PDF files on the web and is one of the most popular Fi... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Download PDF Creator

Download The Best of Planet PDF volume 2
Planet PDF Newsletter
Most Popluar Articles
Features

Collating PDFs using JavaScript

Despite the numerous benefits, there can be potential issues with the conversion of paper documents into electronic archives. When scanning paper pages into PDF, it's possible to end up with the odd- and even-numbered pages in separate PDF files. It can be very time-consuming to collate them manually, but there is an easier way. Sean Stewart explains.

Featured Product

BCL easyPDF SDK

BCL easyPDF SDK is a set of PDF Programming Libraries designed specifically to help Software Developers / Programmers build and deploy enterprise class PDF applications for corporate wide PDF...

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit