htmlcssitextmarginflying-saucer

How to move footer to the space of margin-bottom space used in @page


I have the following @page

@page {
    size: 210mm 297mm;
    background: white;
    display: block;
    margin-bottom: 15%; // eliminates the page size on the bottom
}

I need to show footer to this left-out margin using flying-saucer-pdf version 9.1.22.

I tried the following code but it's not working:

@media print {
        div.divFooter {
                margin-bottom: -15% !important; // I need to take advantage of the free space of @page margin bottom
                padding: 0;
                box-sizing: border-box;
                position: fixed;
                bottom: 0;
                height: 80px;
                z-index: 1; 
        }
}

Solution

  • I found the solution thanks to this, this and this pages.

    @page {
       size: 210mm 297mm;
       background: white;
       margin-bottom: 2.3cm;
       @bottom-left {
          vertical-align: top;
          content: element(footer);
          padding-top: 1px;
          border-top:1px solid #777;
       }
       @bottom-center {
          border-top:1px solid #777;
       }
       @bottom-right {
          border-top:1px solid #777;
       }
    
    }
    footer {
       margin-top: 0.1cm;
       display: block;
       position: running(footer);
       font-size: 8pt;
       line-height:1.0;
    }
    

    And my html code contains the following element:

    <footer>
       <p style="font-size: 10pt;"><b>Note(s)</b></p>
       <p>This is a printed copy.</p>
    </footer>
    

    Comment: Do not use position: block in body or @page because running() won't work.