spacer

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

home / experts / javascript / column93


Print Templates, Part IV: User's Settings

Subject Matter Expert - Managed Services (PA)
Next Step Systems
US-PA-Wayne

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


Assembling the Pages

The functions addFirstPage() and addNextPage() assemble the pages. Each page consists of a LAYOUTRECT element within a DEVICERECT element. Here is the first page definition:


newHTML  = "<IE:DEVICERECT ID='devicerect1'
  MEDIA='print' CLASS='masterstyle'>";
newHTML += "<IE:LAYOUTRECT ID='layoutrect1' CONTENTSRC='document'
  ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect2'
  CLASS='contentstyle'/>";
newHTML += "</IE:DEVICERECT>";

The LAYOUTRECT element ID is a concatenation between the string "layoutrect" and the page number (1). The CONTENTSRC attribute specifies the formatted document. The value "document" means the current document. The LAYOUTRECT element points to the next page's LAYOUTRECT element ID (layoutrect2). The CLASS definitions ensure the page will be formatted according to the STYLE rules contentstyle and masterstyle.

After defining the first page's HTML, we insert it in the page:

pagecontainer.insertAdjacentHTML("afterBegin", newHTML);

The textHead and textFoot properties get the instructions as to how to assemble the header and the footer, as they are defined by the user in the Page Setup dialog box:

myheaderfooter.textHead = printer.header;
myheaderfooter.textFoot = printer.footer;

The headerFooter's URL and title properties are extracted from the current document object. The object is passed in dialogArguments._IE_BrowseDocument:

myheaderfooter.url = dialogArguments.__IE_BrowseDocument.URL;
myheaderfooter.title = dialogArguments.__IE_BrowseDocument.title;

Finally, we set the templatePrinter's page number:

myheaderfooter.page = 1;

and we add the header and the footer:

addHeaderAndFooterToPage(1);

The function addNewPage() is very similar. It assembles a LAYOUTRECT element within a DEVICERECT element. The ID entries are created from the current page number, lastPage. Here is addNewPage():

function addNewPage() {
  document.all("layoutrect" + lastPage).onlayoutcomplete = null;
  myheaderfooter.page = lastPage + 1;

  newHTML  = "<IE:DEVICERECT ID='devicerect" + (lastPage + 1) +
    "' MEDIA='print' CLASS='masterstyle'>";
  newHTML += "<IE:LAYOUTRECT ID='layoutrect" + (lastPage + 1) +
    "' ONLAYOUTCOMPLETE='onPageComplete()' NEXTRECT='layoutrect" +
    (lastPage + 2) + "'  CLASS='contentstyle'/>";
  newHTML += "</IE:DEVICERECT>";

  pagecontainer.insertAdjacentHTML("beforeEnd", newHTML);
  addHeaderAndFooterToPage(lastPage + 1);
  lastPage++;
}

Next: How to print the pages


http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


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

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