通过前面的介绍,大家应该对DeviceRect和LayoutRect有了一个分别的了解。下面我们就看一下如何联合起来使用他们。对每一个格式的页页,你需要有一个包含内容页(LayoutRect)的Master Page(DeviceRect)。第一页 与其他要不同,因为他包含有指明打印源的CONTENTSRC属性。

学78M网FL7页6sh68网(http://www.xwangye.com)

这是一个第一页的DeviceRect对象:

以下是示例代码:
<IE:DEVICERECT ID="page1" CLASS="masterstyle"
  MEDIA="print">
	<IE:LAYOUTRECT ID="layoutrect1"
  CONTENTSRC="2.html"
    CLASS="contentstyle" NEXTRECT="layoutrect2"/>
</IE:DEVICERECT> 

学78M网FL7页6sh68网(http://www.xwangye.com)

下面是第二页的DeviceRect对象

学78M网FL7页6sh68网(http://www.xwangye.com)

以下是示例代码:
<IE:DEVICERECT ID="page2" CLASS="masterstyle"
  MEDIA="print">
<IE:LAYOUTRECT ID="layoutrect2"
  CLASS="contentstyle"/>
</IE:DEVICERECT>

学78M网FL7页6sh68网(http://www.xwangye.com)

下面我们查看完整的打印模板的代码

学78M网FL7页6sh68网(http://www.xwangye.com)

以下是示例代码:
<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>

学78M网FL7页6sh68网(http://www.xwangye.com)

 仔细看学习上面的代码。下面的文章我们将学习一下如何动态创建打印页。

学78M网FL7页6sh68网(http://www.xwangye.com)