spacer
Yehuda Shiran September 25, 2001
Converting Dimensions for Printing
Tips: September 2001

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Google Going Native With Chrome
Mozilla Fixes Firefox Flaws as 3.5 Release Nears
Microsoft and Novell Still Bosom Buddies

The behavior templatePrinter has all the properties to define the content area, the master page, the header, and the footer. These properties reflect the values you enter in the Page Setup dialog box and the Print Dialog box. All dimensions are stored in templatePrinter as inches. The style object, on the other hand, expects dimensions to be in 1/100th of an inch. Therefore, you need to divide the templatePrinter's settings by 100 before storing them in the style object. You also need to append the "in" dimension to every numeric value. Let's see a few examples. In these examples, assume there is a templatePrinter element with ID="printer", the master page's style object is oMasterStyleClass, and the content's style object is oContentStyleClass.

Let's start with the master page's width and height:

oMasterStyleClass.style.width = printer.pageWidth/100 + "in";
oMasterStyleClass.style.height = printer.pageHeight/100 + "in"; 
The margins of the content with respect to its container master page are set next:

oContentStyleClass.style.marginTop = printer.marginTop/100 + "in"; 
oContentStyleClass.style.marginLeft = printer.marginLeft/100 + "in";

People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
XML and PHP Simplified · Creating a ASP.NET Contact Form · Data Filtering with PHP
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Intel to Host Live Nehalem Q&A · 12 Tips to Troubleshoot Network File-Sharing · 10 Tips for Selling on Kijiji