title: FPDF Multiple Documents Generated In One PDF, Need To Reset Page No Per Document
body: <p>I am using FPDF to generate invoices and I had to work around an issue when printing multiple documents.  I am generating multiple (anywhere from 2 to 100+) invoices for print so I built a foreach loop around my FPDF code to put all my invoices in one PDF so I can hit print and be done.  The problem is, FPDF uses PageNo() and {nb} to generate page numbers and the total page count in the header and if I have 500 pages it lists as Page: 1 of 500, Page: 2 of 500, Page: 3 of 500...  etc.</p>
  
  <p>I need to figure out a way to generate a page count and current page by invoice.  So if the first invoice is 3 pages it says Page: 1 of 3, Page: 2 of 3, etc. and the next invoice is 5 pages, Page: 1 of 5, Page: 2 of 5, etc. ...even though it's all in the same PDF.</p>
  
  <pre><code>    $pdf=new PDF();
      foreach ($array_invoices as $invoice_number) {
  
              ...FPDF Template Here...
  
              /**
               * The following code checks the page length
               * If the page is over a certain length it will create a new page.
               * If not, it will add the footer.
               */
  
              if($pdf-&gt;GetY() &lt; 225)
                      $pdf-&gt;SetY(238);
              elseif($pdf-&gt;getY() &gt; 240)
                      $pdf-&gt;AddPage();
      }
  
      $pdf-&gt;Output();
  </code></pre>
  
  <p>The template has an include to the header which outputs the page number...</p>
  
  <pre><code>$this-&gt;Cell(94,0,'page '.$this-&gt;PageNo().'/{nb}' ,0,0,'R');
  </code></pre>