0

I am using a basic html structure for my PDF template together with <htmlpagefooter> according to the mPDF docs. A sample implementation can be found here

<html>
  <head>
    <style>
        .mydiv {
            color: red;
        }
    </style>
  </head>
  <htmlpagefooter name="myfooter">
      Page {PAGENO} of {nb}
  </htmlpagefooter>

  <sethtmlpagefooter name="myfooter" value="on" />
  <body>
    <div class="mydiv">
        This is my PDF file
    </div>
  </body>
</html>

When I generate my PDF it will refuse to show the footer on any page. When I put PHP code inside it will throw an appropriate error proving that it is parsed into the mPDF.

Maarten
  • 402
  • 5
  • 20

1 Answers1

0

Because you are using a <body> tag inside an <html> tag, you have to make sure your footer is included in code that will be rendered on a page.

When you include the footer outside of the body, it will not be shown in the PDF.

When you include the footer inside the body, it will render as expected.

So a succesfull implementation of a footer in mPDF would look like this;

<html>
  <head>
    <style>
        .mydiv {
            color: red;
        }
    </style>
  </head>
  <body>
    <htmlpagefooter name="myfooter">
        Page {PAGENO} of {nb}
    </htmlpagefooter>
  
    <sethtmlpagefooter name="myfooter" value="on" />
    <div class="mydiv">
        This is my PDF file
    </div>
  </body>
</html>
Maarten
  • 402
  • 5
  • 20