Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I add a Header to a report?

Status
Not open for further replies.

NoWayIsThisInUse

IS-IT--Management
Jul 16, 2002
79
US
Does anyone have an example of a simple header to appear on each printed page?
I just want to have a client's name at the top of each page on an html report (in ColdFusion 5.0) for IE 6+ users.
I found the following on but it's a bit more than what I need. (It does a Page x of x header or footer.)

<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
{
background:#FFFF99;
border-left:1 solid black;
border-top:1 solid black;
border-right:4 solid black;
border-bottom:4 solid black;
width:8.5in;
height:11in;
margin:10px;
overflow:hidden;
}
.headerstyle
{
position:absolute;
top:.25in;
width:5.5in;
left:1in;
}
.footerstyle
{
position:absolute;
top:10.5in;
width:5.5in;
left:1in;
}
</STYLE>
<SCRIPT LANGUAGE="JavaScript">
<!--
var lastPage = 1;

function addFirstPage() {
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>";

devicecontainer.insertAdjacentHTML("afterBegin", newHTML);

myheaderfooter.textHead = printer.header;
myheaderfooter.textFoot = printer.footer;
myheaderfooter.url = dialogArguments.__IE_BrowseDocument.URL;
myheaderfooter.title = dialogArguments.__IE_BrowseDocument.title;
myheaderfooter.page = 1;
addHeaderAndFooterToPage(1);
}

function onPageComplete() {
if (event.contentOverflow == true) {
addNewPage();
}
else {
myheaderfooter.pageTotal = document.all.tags("DEVICERECT").length;
for (i = 1; i <= myheaderfooter.pageTotal; i++) {
addPageTotalToPages(i);
}
}
}

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>";

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

function addHeaderAndFooterToPage(pageNum) {
newHeader = "<DIV CLASS='headerstyle'>" + myheaderfooter.htmlHead + "</DIV>";
newFooter = "<DIV CLASS='footerstyle'>" + myheaderfooter.htmlFoot + "</DIV>";

document.all("devicerect" + pageNum).insertAdjacentHTML("afterBegin", newHeader);
document.all("devicerect" + pageNum).insertAdjacentHTML("beforeEnd", newFooter);
}

function addPageTotalToPages() {
oSpanCollection = document.all.tags("span");
for (i = 0; i < oSpanCollection.length; i++) {
if (oSpanCollection.className == "hfPageTotal") {
oSpanCollection.innerText = myheaderfooter.pageTotal;
}
}
}
// -->
</SCRIPT>
</HEAD>

<BODY ONLOAD="addFirstPage()">

<IE:TEMPLATEPRINTER ID="printer"/>
<IE:HEADERFOOTER ID="myheaderfooter"/>

<DIV ID="devicecontainer">
<!-- Dynamically created pages go here. -->
</DIV>

</BODY>
</HTML>
 
Is it possible to use the title tag for this purpose?

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
I'd point you here: but something is screwing with the link in that post...

Try the url in the code box below:
Code:
[URL unfurl="true"]http://www.webmasterworld.com/f[/URL][b]orum[/b]83/21.htm

Ignore the odd bold formatting, but its trying to screw with the link again if I don't format part of it bold (that disrupts the link... thing)

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Check out the HTML CSS forum and see if there is anything they can do using CSS. This isn't a CF question.

here is the link forum215

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
The problem with HTML is it isn't designed for the printer as far as media goes. Some CSS rules can help but i think IE is the only browser that supports the page break rules. The best thing to do is to use a reporting tool if your servers have one. crystal reports and cognos are common tools.

Human beings, who are almost unique in having the ability to learn from the experience of others, are also remarkable for their apparent disinclination to do so.
-Douglas Adams (1952-2001)
 
They said IE6+ so it sounds like mostly an in-office thing.

But yeah, you're right, that's why most people don't know about the media attribute of the style tag and other things, because these can't come fast because noone works together.

For instance, XML is a "standard" but other people were inspired so much by XML that they created their own.

Its more helpful to everyone to work together on one thing than to work seperately... Sure some innovation comes when people take things their own way, but when most platforms can't use it, it does no good.

I'm rambling now, I'll be on my way.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top