itajackass
itajackass

Reputation: 488

TCPDF show total invoice in footer only in last page

I've already ask with another account but i can't access it to add more info to the post, so i'll rewrite here.

I've tried with:

class MYPDF extends TCPDF {

 // ... some code

 public function Footer() {

    $actualPage = $this->getAliasNumPage();
    $totalPages = $this->getAliasNbPages();

    // ....

    $result = $actualPage == $totalPages ? "LAST" : "NOT LAST";

    $this->writeHTML($actualPage . " / " . $totalPages . ": " . $result, false, false, true, false, '');

}
}

For example if I've 2 pages i get this:

1 / 2: NOT LAST

2 / 2: NOT LAST

Using var_dump() i get those info: string '{:pnp:}' and string '{:ptp:}'

In the real word i'm using it to generate an invoice and show the total of the document only on the last page.

Upvotes: 0

Views: 1417

Answers (1)

itajackass
itajackass

Reputation: 488

Solved with this solution: TCPDF Change Footer on last page

class mypdf extends tcpdf {

  protected $last_page_flag = false;

  public function Close() {
    $this->last_page_flag = true;
    parent::Close();
  }

  public function Footer() {
    if ($this->last_page_flag) {
      // ... footer for the last page ...
    } else {
      // ... footer for the normal page ...
    }
  }
}

Upvotes: 1

Related Questions