Search code examples
mpdf

How can I get the current page number in mPDF v7?


I want to change something on the page for multi-page documents, depending on which page number is currently being assembled. As I loop through the items being output, is there a way to check the current page number programmatically? (I do not want to simply print the current page in the PDF.)


Solution

  • You can use

    $mpdf = new Mpdf\Mpdf();
    $pageNumber = count($mpdf->pages);
    

    But the $pages property of the object is internal and access to it may be disabled in future versions.