title: TCPDF Change Footer on last page
body: <p>I am trying to create a pdf using TCPDF and need a different footer on the last page</p>
  
  <p>using the following code I can get a different footer on the first page but not the last</p>
  
  <p>I have looked at several post about this but can not make it work</p>
  
  <p>Any help implementing this would be much appreciated</p>
  
  <pre><code>public function Footer() {
      $tpages = $this-&gt;getAliasNbPages();
      $pages = $this-&gt;getPage();
  
      $footer = 'NORMAL' . $pages . $tpages;
  
      if ($pages == 1 ) $footer = 'FIRST' . $pages . $tpages;
      if ($pages == $tpages) $footer = 'LAST' . $pages . $tpages;
  
      $this-&gt;Cell(0, 10, $footer, 0, false, 'C', 0, '', 0, false, 'T', 'M');
  }
  </code></pre>
  
  <p>This gives me</p>
  
  <p>page1 - FIRST13
  page 2 - NORMAL23
  page 3 (Last Page) NORMAL23 </p>
  
  <p>Answer:</p>
  
  <pre><code>public function Footer() {
      $tpages = $this-&gt;getAliasNbPages();
      $pages = $this-&gt;getPage();
  
      $footer = 'NORMAL' . $pages . $tpages;
  
      if ($pages == 1 ) $footer = 'FIRST' . $pages . $tpages;
      if ($this-&gt;end == true) $footer = 'LAST' . $pages . $tpages;
  
      $this-&gt;Cell(0, 10, $footer, 0, false, 'C', 0, '', 0, false, 'T', 'M');
  }
  
  function display() {
      #function that has main text
      $this-&gt;AddPage();
      $html = '1st page';
      $this-&gt;writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
       $this-&gt;AddPage();
      $html = '2nd page';
      $this-&gt;writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
  
       $this-&gt;AddPage();
      $html = 'Last page';
      $this-&gt;writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);   
    $this-&gt;end = true;
  }    
  </code></pre>