2

I am creating a web based billing system, in which I have to generate bill pdfs of multiple pages.

The problem is: I want to print the footer at the bottom of last print page.

#footer{
  position: fixed;
  bottom: 0px;
  width:100%;
}

This code is printing footer on every page, but I want it only on last page.

2 Answers2

0

Add this to your stylesheet, see if it helps you:

@media print { 
body {
  position: relative;
  }
#footer {
  position: absolute;
  bottom: 0;
  }
}

Reference: html footer at last page

bhansa
  • 7,282
  • 3
  • 30
  • 55
0

In addition to @bhansa answer

<style>
    @media print { 
    body {
      position: relative;
      }
    #footer {
      position: absolute;
      bottom: 0;
      }
    .empty {
        height: 150px;
        width: 100%;
       }
    }
</style>

<body>
    <div class="content">Somebody</div>
    <div class="empty"><div>
    <div id="footer" style="height=150px; width=100%">Footer</div>
</body>

In order not to overlap the content, add an empty div after the content that matches the height of the footer