Tiffy Posted August 23, 2013 Share Posted August 23, 2013 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 More sharing options...
trq Posted August 23, 2013 Share Posted August 23, 2013 You seem to already have your logic sorted (kinda), we cant really help without seeing some code. Link to comment https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/#findComment-1446419 Share on other sites More sharing options...
Tiffy Posted August 23, 2013 Author Share Posted August 23, 2013 yes i have got the logic sorted out. But not sure how to get the value of total page count. Link to comment https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/#findComment-1446425 Share on other sites More sharing options...
Tiffy Posted August 23, 2013 Author Share Posted August 23, 2013 somthing like that..... function Footer() { if($this->PageNo() < '{nb}') { $this->SetY(-20); $this->SetFont('Arial','',; $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','',; $this->Cell(0,3,"content for the last page",0,1,'C');//always displayed } $this->SetFont('Arial','',; $this->SetTextColor(0,0,0); $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,1,'C'); } Link to comment https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/#findComment-1446429 Share on other sites More sharing options...
darkfreaks Posted August 23, 2013 Share Posted August 23, 2013 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. Link to comment https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/#findComment-1446471 Share on other sites More sharing options...
trq Posted August 24, 2013 Share Posted August 24, 2013 add this to the main functions in MPDF No one mentioned MPDF. Link to comment https://forums.phpfreaks.com/topic/281487-get-nb-value-for-total-page-count/#findComment-1446518 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.