Update I played a little with the code above, and this may work easier than I originally thought. (Note that there is a possibility that the footer overlaps the content from the previous div, this could be solved by adding the margin-bottom attribute to the content of the div equal to the height of the custom footers. Also, if your page content is too large between the gaps pages, it will still have several scripts that need to be visited). All that said, I tested on the spot, and it worked the way you wanted.
CSS
<style> @media print{ .footer{ position:relative; top:-20px;
HTML
<body> <div style="page-break-after: always"> <div>This should be on top1</div> </div> <div style="page-break-after: always"> <div class="footer">This should be on bottom of page1</div> <div>This should be on top2</div> </div> <div class="footer">This should be on bottom of page2</div> </body>
Original answerUnfortunately, there is no easy way to do this. Browsers do not offer the means to create custom headers and footers for printing. A.
Itβs best to place the right information on every page in the title tag found in <head><title>YOUR COMMON CONTENT</title></head> This will not be the most beautiful. It comes down to your requirements.
Another option is to use @media print (CSS) in conjunction with javascript to dynamically compute and insert gaps / spaces in spaces when inserting a div (your custom footer and / or header) into absolute positions for a known paper format, then dynamically after the print event change the format back.
Arthur weborg
source share