title: TCPDF is adding an extra blank page at the end
body: <p>I'm using the following code to generate pdf. It is adding a blank page at the end in some cases(In the last tr,If I give more more lines in the td it is moving to second page but if I give few lines then it is adding a blank page at the end)</p>
  
  <p>Here is my code:</p>
  
  <pre><code>// set default monospaced font
  $pdf-&gt;SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  
  // set margins
  $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $pdf-&gt;SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);
  
  // set auto page breaks
  $pdf-&gt;SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  
  // set some language-dependent strings (optional)
  if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
      require_once(dirname(__FILE__).'/lang/eng.php');
      $pdf-&gt;setLanguageArray($l);
  }
  
  // set font
  $pdf-&gt;SetFont('helvetica', '', 8);
  
  // add a page
  $pdf-&gt;AddPage('P');
  
  $html = '&lt;style type="text/css"&gt;
      th, td{
          border:1px solid #ccc;
      }
      &lt;/style&gt;
      &lt;table id="maintable" border="1" cellspacing="0" cellpadding="3" style="border:1px solid #cccccc;"&gt;
           &lt;tr bgcolor="#dddddd" nobr="true"&gt;
           &lt;th align="center" width="40px"&gt;'.LBL_PDF_EQUIPER_ID.'&lt;/th&gt;
           &lt;th align="left" width="100px"&gt;'.LBL_PDF_EQUIPER_NOM_PRENOM.'&lt;/th&gt;
           &lt;th align="left" width="175px"&gt;'.LBL_PDF_EQUIPER_EMAIL.'&lt;/th&gt;
           &lt;th align="center" width="100px"&gt;'.LBL_PDF_EQUIPER_TELEPHONE.'&lt;/th&gt;
           &lt;th width="120px"&gt;'.LBL_PDF_EQUIPER_ADRESSE.'&lt;/th&gt;
           &lt;/tr&gt;';
  foreach($records as $record){       
      $comm_related_set = $record-&gt;getRelatedSet('con_sec__con__COMM');
      $email = "";
      $telephone = "";
      $html .= '&lt;tr padding="0" nobr="true"&gt;
      &lt;td align="center" width="40px"&gt;'.trim($record-&gt;getField('con_sec__USR::__kp__UsrId__lsan')).'&lt;/td&gt;
      &lt;td align="left" width="100px"&gt;'.trim($record-&gt;getField('con_sec__CON::NOM_Prenom_Societe')).'&lt;/td&gt;
      &lt;td align="left" width="175px"&gt;'.trim(implode('&lt;br/&gt;', $email)).'&lt;/td&gt;
      &lt;td align="left" width="100px"&gt;'.trim(implode('&lt;br/&gt;', $telephone)).'&lt;/td&gt;
      &lt;td width="120px"&gt;'.preg_replace('/[\n\r]/','&lt;br/&gt;',trim($record-&gt;getField('con_sec__con__ADDR::Address_comp_display_PHP'))).'&lt;/td&gt;
  &lt;/tr&gt;';
  }
  
  $html .= '&lt;/table&gt;';
  
  // output the HTML content
  //echo $html; exit;
  $pdf-&gt;writeHTML($html, false, false, true, false, '');
  $pdf-&gt;lastPage();
  
  $fileName = 'Liste';
  //Close and output PDF document
  $pdf-&gt;Output($fileName . '.pdf', 'D');
  </code></pre>
  
  <p>I tried <a href="https://stackoverflow.com/questions/22600329/how-tcpdf-prevent-the-extra-blank-page/39356741#39356741">this</a> solution from stackoverflow but it is not working for me. Can someone help me to fix this extra blank page issue?</p>