Print Templates, Part I: Content Rendering - Doc JavaScript
Print Templates, Part I
Content Rendering
The LayoutRect
behavior formats the page content itself. You need one LayoutRect
per page. The LayoutRect
element is defined inside the DeviceRect
element. The content of each LayoutRect
element is limited to one page. Once a page is filled, formatting jumps to the next page automatically. You need to define LayoutRect
's style, as you did for DeviceRect
. Suppose we want the content portion of the page to have the following characteristics:
- 5.5 inches wide
- 8 inches high
- 1 inch margin from all sides
- White background
- 1 inch wide gray dashed border
We can define a style, contentstyle
, as follows:
<STYLE TYPE="text/css"> .contentstyle { width:5.5in; height:8in; margin:1in; background:white; border:1 dashed gray; } </STYLE>
We can use the LayoutRect
elements to format any content. Examine what the second page of this column looks like with the style above. Here is the HTML code:
<HTML> <HEAD> <?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default"> <STYLE TYPE="text/css"> .contentstyle { width:5.5in; height:8in; margin:1in; background:white; border:1 dashed gray; } </STYLE> </HEAD> <BODY> <IE:LAYOUTRECT ID="layoutrect1" CONTENTSRC="2.html" CLASS="contentstyle" NEXTRECT="layoutrect2"/> <IE:LAYOUTRECT ID="layoutrect2" CLASS="contentstyle"/> </BODY> </HTML>
This HTML code is similar to the example on the previous page except that DeviceRect
is replaced with LayoutRect
. Again, DeviceRect
formats the master page, while LayoutRect
formats the content. Notice the attributes of LayoutRect
above. The ID
attribute needs to be unique per page. The CONTENTSRC
attribute specifies the URL of the content to be formatted. Here we specify Page 2 of this column. The CLASS
attribute links the element with its designated style definition, contentstyle
. For each page, you need to specify which element is next in line to hold the content overlfow. Use the NEXTREC
attribute to list the ID
of the next LayoutRect
element. In our case above, we include only two pages, and indeed you can see that Page 2 does not need more than two pages.
Next: How to create a static print template with DeviceRect
and LayoutRect
Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: July 30, 2001
Revised: July 30, 2001
URL: https://www.webreference.com/js/column89/4.html