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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

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, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business