'How to get the total number of pages in MPDF?
I'm using PHP MPDF to create PDF files. At the footer I'm able to print the current page number using
{PAGENO}
But how do I get the total number of pages in the PDF file? So that in the footer I can print like:
Page (Current Page) of (Total number of pages)
Page 1 of 6
Solution 1:[1]
According to the official documentation:
$mpdf=new mPDF();
$mpdf->setFooter("Page {PAGENO} of {nb}");
Solution 2:[2]
you can use {nb} it gives you total number of pages in mpdf
Solution 3:[3]
I use the following in my html header template :
{PAGENO}/{nb}
For example,on 1st of total of 3 pages, the result will be :
1/3
So, you can write it wherever you want in your HTML code like header, footer, body...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sr9yar |
| Solution 2 | Newton |
| Solution 3 | Meloman |
