spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column89


Print Templates, Part I

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

Writing a Static Print Template

Now that we know what DeviceRect and LayoutRect elements look like separately, let's see how to combine between them. For each formatted page, you need to have a master page (DeviceRect) which includes a content page (LayoutRect). The first printed page is different from the other pages because you need to include the CONTENTSRC attribute which specifies the content source. Here is the DeviceRect element for the first page:

<IE:DEVICERECT ID="page1" CLASS="masterstyle"
  MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect1"
  CONTENTSRC="2.html"
    CLASS="contentstyle" NEXTRECT="layoutrect2"/>
</IE:DEVICERECT> 

And here is the DeviceRect element of the second page:

<IE:DEVICERECT ID="page2" CLASS="masterstyle"
  MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect2"
  CLASS="contentstyle"/>
</IE:DEVICERECT>

Let's learn how to assemble the complete code that will format our 2.html page. First, look at the outcome. Then, look at the code that does it:

<HTML XMLNS:IE>
<HEAD>
<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">
<STYLE TYPE="text/css">
.contentstyle
{
  width:5.5in;
  height:8in;
  margin:1in;
  background:white;
  border:1 dashed gray;
}
.masterstyle
{
  width:8.5in;
  height:11in;
  background:#FFFF99;
  border-left:1 solid black;
  border-top:1 solid black;
  border-right:4 solid black;
  border-bottom:4 solid black;
  margin:10px;
}
</STYLE>
</HEAD>

<BODY>
<IE:DEVICERECT ID="page1" CLASS="masterstyle"
  MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect1"
  CONTENTSRC="2.html"
    CLASS="contentstyle" NEXTRECT="layoutrect2"/>
</IE:DEVICERECT>

<IE:DEVICERECT ID="page2" CLASS="masterstyle"
  MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect2"
  CLASS="contentstyle"/>
</IE:DEVICERECT>

</BODY>
</HTML>

Next: How to dynamically create the first page

http://www.internet.com

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


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: July 30, 2001
Revised: July 30, 2001

URL: http://www.webreference.com/js/column89/5.html