I'm struggling to repeat the header and footer on each print page. No problem necessarily be a table, most like it was, someone has any idea how to do? And i dont know how many pages it will be, can be n pages.
Asked
Active
Viewed 3,112 times
3
-
can you post some code? – D. Cantatore Aug 25 '16 at 17:01
-
I found no code to do this, the closer I saw was this: http://jsfiddle.net/7ZGVv/111/ .But can not repeat the header nor footer. – Danilo Pádua Aug 25 '16 at 17:02
-
Possible duplicate of [How to use HTML to print header and footer on every printed page of a document with 5 pages?](http://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page-of-a-document-w) – Adam Buchanan Smith Aug 25 '16 at 17:21
-
1@AdamBuchananSmith it isn`t the same. – Pedro Franco Aug 25 '16 at 17:56
-
@PedroFranco it is in fact exactly what is needed. – Adam Buchanan Smith Aug 25 '16 at 18:03
-
@PedroFranco see my answer below, please explain how this does not work? – Adam Buchanan Smith Aug 25 '16 at 18:26
-
1@Danilo see the working example below. – Adam Buchanan Smith Aug 25 '16 at 18:27
2 Answers
2
Well since no-one seems to think it is a dup, I will post the code here to prove it. See a working example here http://a-b-smith.com/
html
<h1>test 1</h1>
<h1>test 2</h1>
<h1>test 3</h1>
<h1>test 4</h1>
<h1>test 5</h1>
<h1>test 6</h1>
<div class="divFooter">
<h1>Footer</h1>
</div>
<div class="divHeader">
<h1>Header</h1>
</div>
CSS note I added a page break in between each of the <h1>
to simulate multiple pages
@media print {
h1 {
page-break-after: always;
}
div.divFooter {
position: fixed;
bottom: 0;
}
div.divHeader {
position: fixed;
top: 0;
}
body > h1 {margin-top: 100px;}
}
@media screen {
div.divFooter, div.divHeader {
display: none;
}
}

Adam Buchanan Smith
- 9,422
- 5
- 19
- 39
1
HTML and CSS have no support for printing page header and footers in print. You may be able to simulate it with:
- tables
- fixed position blocks
This solution have each bug and caveat in different browser.
See : How to use HTML to print header and footer on every printed page of a document?

Community
- 1
- 1

Gerald Chablowski
- 462
- 2
- 7