title: TCPDF displays blank PDF if query result is big
body: <p>I have a search form wherein it allows PDF download whenever you enter a search query on it. The problem here is that I can only download the PDF if there are only few numbers of result..</p>
  
  <p>If result exceeds 80 records, it displays a blank page..</p>
  
  <p>Please Advice,
  Thanks.!</p>
  
  <p>here's 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 image scale factor
  $pdf-&gt;setImageScale(PDF_IMAGE_SCALE_RATIO);
  
  //set some language-dependent strings
  $pdf-&gt;setLanguageArray($l);
  
  // ---------------------------------------------------------
  
  
  // add a page
  $pdf-&gt;AddPage();
  
  $pdf-&gt;Write(0, $order_type, '', 0, 'L', true, 0, false, false, 0);
  
  $pdf-&gt;SetFont('helvetica', '', 7);
  
  // -----------------------------------------------------------------------------
  
  ob_start();
  
  if(!($query = mysql_query($this-&gt;sql)))
      throw new Exception(mysql_error());
  
  if(($field_name=mysql_num_fields($query)) &gt; 0) {
      $tableheader = '&lt;table&gt;';
      $tableheader .= '&lt;tr&gt;';
      $tableheader .= '&lt;td&gt;Rows&lt;/td&gt;';
      for($x=0;$x&lt;$field_name;$x++) {
          $tableheader .= '&lt;td&gt;'.mysql_field_name($query,$x).'&lt;/td&gt;';
          if($x==10)
              break;
      }
      $tableheader .= "&lt;/tr&gt;";
  }
  
  if(mysql_num_rows($query)) {
      $row = 1;
      while($field = mysql_fetch_assoc($query)) {
          if($row == 1) {
              echo $tableheader;
          }
  
          echo "&lt;tr&gt;";
          echo "&lt;td&gt;{$row}&lt;/td&gt;";
          foreach($field as $val) {
              echo "&lt;td&gt;{$val}&lt;/td&gt;";
          }
          echo "&lt;/tr&gt;";
  
          if($row==85) {
              break;
          }
          $row++;
      }
      echo "&lt;/table&gt;";
  }
  
  $html = ob_get_contents();
  ob_end_clean();
  
  $pdf-&gt;writeHTML($html, true, false, true, false, '');
  $pdf-&gt;lastPage();
  
  // -----------------------------------------------------------------------------
  
  
  //Close and output PDF document
  $pdf-&gt;Output("memberdata.pdf", 'I');
  </code></pre>