Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to print a different footer on every page?

Tags:

html

css

printing

I'm converting an Access application to web, and need to print reports from it. These are letters mailed out and so the bottom of the letter, which is the 'please return' portion, will always be at the bottom of the page, regardless of how big the body of the letter is. I've used DIVs to lay out the letters and mimicked Access quite well, but I don't know how to get each letter's header at the bottom of its page. Using the CSS position: fixed; for the footer just makes every footer show up at the bottom of every page, and we would like to be able to print off multiple letters at once.

If I remove the fixed, it does display each footer on its own page, they weren't aligned to the bottom of it.

Can I have my cake and eat it too? Doesn't need to be cross-browser, and I'll move to PDF if absolutely necessary, but what are my options in CSS/HTML? Somehow converting it all to a table and trying out tfoot? But will that enforce it to be at the bottom of each page?

Edit: A sample of the CSS/HTML:

.reportcontainer {
    width: 100%;
    page-break-inside: avoid;
    page-break-after: always;
    position: relative;
}
.reportbody {
    float: left;
    text-align: left;
}
.reportfooter {
    width: 100%;
    float: left;
    bottom: 0;
    position: fixed;
}

<div class="reportcontainer">
    <div class="reportbody">
        yadda yadda yadda
    </div>
    <div class="reportfooter">
        stuff goes here
    </div>
</div>
like image 368
Andrew Avatar asked Dec 27 '10 15:12

Andrew


People also ask

How do I make the Footer different on each page word?

Select Layout > Breaks > Next Page. Double-click the header or footer on the first page of the new section. Click Link to Previous to turn it off and unlink the header or footer from the previous section. Note: Headers and footers are linked separately.

Can you have different Headers and footers on each page?

To create a different header or footer for part of a document, you'll need to divide the document into sections, and then break the connection between the header or footer in the current section and the previous one. To do so: Insert section breaks; see ARCHIVED: In Microsoft Word, what are sections?


2 Answers

I would recommend using PDF. If you need that level of control for printed material, you're going to be fighting to get HTML to work across browsers and this is really what PDF is designed for.

tfoot would not help, it only ensures that the footer is at the bottom of the table, not the bottom of the page.

like image 150
Samuel Neff Avatar answered Sep 29 '22 01:09

Samuel Neff


Try this. I've had to figure out a lot of html printing lately as well. You can figure out how you want to replicate the divs, either backend or using jquery cloning for each report. Borders are just to illustrate containers.

.reportcontainer {
    width:8.5in;
    height:11in;
    page-break-inside:avoid;
    page-break-after:always;
    border:1px solid red;
}
.reportbody {
    width:100%;
    height:10in;
    border:1px solid yellow;
}
.reportfooter {
    width:100%;
    height:1in;
    border:1px solid blue;
}
</style>

<div class="reportcontainer">
    <div class="reportbody">
        yadda1 yadda1 yadda1
    </div>
    <div class="reportfooter">
        footer 1 goes here
    </div>
</div>

<div class="reportcontainer">
    <div class="reportbody">
        yadda2 yadda2 yadda2
    </div>
    <div class="reportfooter">
        footer 2 goes here
    </div>
</div>

<div class="reportcontainer">
    <div class="reportbody">
        yadda3 yadda3 yadda3
    </div>
    <div class="reportfooter">
        footer 3 goes here
    </div>
</div>
like image 42
Jay Media Avatar answered Sep 28 '22 23:09

Jay Media