title: TCPDF - How to make the printing faster? It is very very slow, 1320 records took 40 minutes
body: <p>Using Zend framework and TCPDF this is taking 40 minutes to print the Test.pdf. I having now no idea how to reduce this abnormal time to something normal?</p>
  
  <pre><code>set_time_limit(0);
  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  $pdf-&gt;SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE, PDF_HEADER_STRING);
  $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  $pdf-&gt;SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
  $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
  $pdf-&gt;SetHeaderMargin(PDF_MARGIN_HEADER);
  $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);
  $pdf-&gt;SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
  $pdf-&gt;setImageScale(PDF_IMAGE_SCALE_RATIO);
  $pdf-&gt;setLanguageArray($l);
  $pdf-&gt;setFontSubsetting(true);
  $pdf-&gt;SetFont('dejavusans', '', 8, '', true);
  $pdf-&gt;AddPage();
  /* Database mysql gives the records and it is wrapped with &lt;table&gt; */
  $html = "&lt;table&gt;1310 records.... with some simple &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;";
  $pdf-&gt;writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);
  $pdf-&gt;Output('Test.pdf', 'I');
  exit;
  </code></pre>
  
  <p><strong>Follow up:</strong> (tune the performance)</p>
  
  <p>1) php.ini:
  memory_limit = 512M
  max_execution_time = 0</p>
  
  <p>2) Codeing
   $pdf->setFontSubsetting(false); // true to false</p>
  
  <p>3) Debug shows, following taking the whole time</p>
  
  <p>$pdf->writeHTMLCell($w=0, $h=0, $x='', $y='', $html, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=true);</p>