title: Multipage invoice/document in PHP
body: <p><strong>TL;DR:</strong> I have problems with PHP generating PDF's longer than 1 page total.</p>
  
  <hr>
  
  <p>Hello again. My goal is to create a script that will basically get all the important data and create a A4 format PDF invoice/document for printing/mailing/archiving. Generating PDF document is fine as long as the document does not overflow.</p>
  
  <p>I want the invoice pages to be outlined with a border, it should contain:</p>
  
  <ul>
  <li>the needed stuff required for the invoice to be valid</li>
  <li>billed products/other information</li>
  <li>place for supplier/customer signature and stamp or other data</li>
  </ul>
  
  <p>All the pages HAVE to contain header and footer (company logo) and footer (page # of # - Invoice/Document ID - Date and Time - office ID - Printer ID, assigned personnel, whatever someone can ask), as well as border around the document body (under header, above footer). </p>
  
  <p><strong>Everything is fine</strong> as long as the document size is not bigger than</p>
  
  <pre><code>$pageSize-$pageMargins-$header-$footer-$invoiceDataBlock-$signaturesBlock
  </code></pre>
  
  <p>which is basically just like 10 cm for the actual invoiced items. If the document is bigger, I actually create attachment for the invoice manually using spreadsheet editor.</p>
  
  <p>The <em>question</em> is: What can I do to create a multipage PDF document that has no problems like invoiced items overlaying the header/footer? I need to know when to continue on the next page. How do I know this? What is the best way to accomplish this task?</p>
  
  <p>Thank you in advance!</p>