Jump to content

Get {nb} value for total page count


Tiffy

Recommended Posts

Hi,

i need to output the footer only in the last page of my pdf. Is there any way that i can count the total number of pages and then compare the current page value with the last page value? If the current page value is equal to the last page value, then the footer will display.

Help needed here! :)

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/
Share on other sites

somthing like that.....

 

function Footer()
        {
            if($this->PageNo() < '{nb}') {
                $this->SetY(-20);
                $this->SetFont('Arial','',8);
                $this->Cell(0,3,"content for the first pages",0,1,'C');//never displayed as '{nb}' is not defined yet I guess
            }
            else {
                $this->SetY(-20);
                $this->SetFont('Arial','',8);
                $this->Cell(0,3,"content for the last page",0,1,'C');//always displayed
            }
            $this->SetFont('Arial','',8);
            $this->SetTextColor(0,0,0);
            $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,1,'C');
        }

 

 

add this to the main functions in MPDF

 

 

 

function getPageCount() {
return count($this->pages);
}

 

 

then add a html-parser such string:

 

$html = str_replace('{PAGECNT}', $this->getPageCount(), $html);

 

then you can insert  {PAGECNT} in your parsed html to get the page count.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.