spacer

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

home / experts / javascript / column92


Print Templates, Part III: HeaderFooter

Developer News
Google Chrome Playing Catch-Up on Extensions
Open Solutions Alliance Gets New Leadership
Red Hat Spacewalk Expands Linux Management

Adding a HeaderFooter Element

You can call print templates only from C++. Luckily enough, Microsoft prepared a versatile application to which you can specify your own print template and your own page to view and print. To use this application, you need to have it installed. Please save it to one of your hard drives, and then click it twice. See what the application looks like. The first template we explain in this column is template4.html. Download it to your drive from Column92.zip or copy and paste it from Page 7. Once it is on your hard drive, enter its full path name in the Template Source field. Click the Print Preview button to see the effect of the template.

We base our demonstration of the HeaderFooter behavior on the dynamic print template we showed in Column 89. There, we called onPageComplete() whenever a page is completed, in order to start populating the next page in line. Please study Column 89. It will give you a good background to this column.

The first header and footer positioning algorithm we present here is quite simple. We first render all pages, and only then add headers and footers to all pages. We distinguish in onPageComplete() between the case of overflow when a new page should be assembled, and the case when there is no overflow, which means it is the last page:

if (event.contentOverflow == true) {
    addNewPage();
  }
  else if (headersFootersAdded == false) {...

We also set the headersFootersAdded variable to avoid duplicates of headers and footers.

To add headers and footers to a print template, you need to include the HeaderFooter behavior. Put it somewhere in the BODY section of the page:

<IE:HEADERFOOTER ID="myheaderfooter"/>

Notice the XML namespace IE. You need to import it in the HEAD section:

<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">

Next: How to add headers and footers after rendering

http://www.internet.com

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

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

webref The latest from WebReference.com Browse >
Popular JavaScript Framework Libraries: An Overview - Part 3 · Accessing Your MySQL Database from the Web with PHP · Working with the DOM Stylesheets Collection
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
MS Access and MySQL · Cisco AutoQoS: VoIP QoS for Mere Mortals · While VoIP Adoption Explodes in Enterprise, Carrier Spending Lags


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

URL: http://www.webreference.com/js/column92/2.html