title: TCPDF keep together function to keep content on 1 page (PDF generation)
body: <p>I'm wondering if there's a keep together function for TCPDF. I have one for FPDF, but I can't get it to work in TCPDF.</p>
  
  <p>Here's how I see it working within the PDF generation code:</p>
  
  <pre><code>// ... PDF code/stuff
  
  // while not kept together
      // add PDF stuff that should be kept together
  
  // .. more PDF code/stuff
  </code></pre>
  
  <p>I'm thinking the function would return false if the a new page was added, roll back and then do the while loop again.</p>
  
  <p>I do have the following working, but I'd rather it was in a function/method of TCPDF so it was more reusable:</p>
  
  <pre><code>$pdf-&gt;startTransaction();
  $block_page = $pdf-&gt;getPage();
  $print_block = 2; // max 2 tries
  
  while ($print_block &gt; 0) {
      // do PDF stuff
  
      if ($pdf-&gt;getPage() == $block_page) {
          $print_block = 0;
      } else {
          // rollback
          $pdf = $pdf-&gt;rollbackTransaction();
          $pdf-&gt;AddPage();
          $block_page = $pdf-&gt;getPage();
          -- $print_block;
      }
  }
  </code></pre>
  
  <p>It would also be cool if it didn't depend on the built in transaction functionality so transactions can be used within the loop, since things like writeHTML() use transactions.</p>