September 25, 2001 - Converting Dimensions for Printing
September 25, 2001 Converting Dimensions for Printing Tips: September 2001
Yehuda Shiran, Ph.D.
|
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/100
th 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";