Headers and Footers

Headers and Footers can be tricky in mPDF. Please read the docs here: https://mpdf.github.io/headers-footers/headers-footers.html

/** @var RockPdf $pdf */
$pdf = $modules->get('RockPdf');
$pdf
  ->load("/site/test.php")
  ->save(preview: true);

This is a simple example that can help you get started quickly:

<style>
  @page {
    footer: html_footer;
    header: html_header;
    margin-header: 10mm;
    margin-top: 35mm;
    margin-footer: 0mm;
  }

  /*
   * use negative margins to move coloured footer
   * to the very side of the document
   */
  .footer {
    margin-left: -15mm;
    margin-right: -15mm;
  }
</style>
<htmlpageheader name="header">
  <table class="w-full">
    <tr>
      <td class="f15 text-bold border">
        Your Logo
      </td>
      <td class="text-right f10 border">
        Your Address<br>
        Some Road 123<br>
        Some City
      </td>
    <tr>
  </table>
</htmlpageheader>

Page 1
<pagebreak />
Page 2

<htmlpagefooter name="footer">
  <div class="footer section bg-muted py10 px15">
    <table class="w-full f8">
      <tr>
        <td class="text-left w50">
          PDF created with RockPdf
        </td>
        <td class="text-center">
          Your Logo
        </td>
        <td class="text-right w50">
          <span>Page {PAGENO}/{nb}</span>
        </td>
      </tr>
    </table>
  </div>
</htmlpagefooter>
RockPdf - Headers and Footers