Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.