-4

I am using window.print function to print a div content and I need to add custom header and footer which shows on every page. can some one please guide me on this ?

I able to add a header and a footer but thats only at top and bottom of the print document what i can do

I want to repeat them in each page what I want

nihel turki
  • 33
  • 2
  • 5
  • 1
    Usually this is done server-side. Your question is too broad and shows no effort what you tried to achieve it. – A1rPun Feb 15 '16 at 15:15
  • Create a print media query in your CSS and style the elements for printing. – David Feb 15 '16 at 15:19
  • @A1rPun what i want to achieve is to add a custom header and footer in each page when printing. example: [link](http://i.stack.imgur.com/BWatZ.png) – nihel turki Feb 15 '16 at 15:50
  • https://stackoverflow.com/questions/1360869/how-to-use-html-to-print-header-and-footer-on-every-printed-page-of-a-document – Saahithyan Vigneswaran Jun 11 '21 at 14:30

2 Answers2

1

Usualy you are not allowed to overwrite header and footer. (defaulted by browser - optional on users choice)

Did you try something like this?

.footer { position: absolute; bottom: 0; }
.header { position: absolute; top: 0; }
Jax-p
  • 7,225
  • 4
  • 28
  • 58
0

try this:

    var pageHeight = parseInt($('body').css('height'))
 var offsetHeight=1230;
    for(var i=0;i<pageHeight;i++){
        if(i%offsetHeight==0 || i==0){
         $('body').append('<div style="position: absolute;top:'+i+';">your header</div>')
        }
    }
yue can play with offsetHeight