title: How to make a good PDF table using PHP?
body: <p>I just want to ask about creating a good pdf table using PHP? There are cells in the table that needs to be multicell, the problem is, I can't make the height of the other cells the same as of those in multicells. Here's the whole code for the PDF generation (I was searching for codes on the web and try if it's working, I haven't finished revising this code).</p>
  
  <pre><code>&lt;?php
  //============================================================+
  // File name   : example_004.php
  // Begin       : 2008-03-04
  // Last Update : 2013-05-14
  //
  // Description : Example 004 for TCPDF class
  //               Cell stretching
  //
  // Author: Nicola Asuni
  //
  // (c) Copyright:
  //               Nicola Asuni
  //               Tecnick.com LTD
  //               www.tecnick.com
  //               info@tecnick.com
  //============================================================+
  
  /**
   * Creates an example PDF TEST document using TCPDF
   * @package com.tecnick.tcpdf
   * @abstract TCPDF - Example: Cell stretching
   * @author Nicola Asuni
   * @since 2008-03-04
   */
  
  // Include the main TCPDF library (search for installation path).
  require_once('tcpdf_include.php');
  include('../../../conn.php');
  $sql = mysql_query("SELECT * FROM tbl_video LIMIT 10");
  // create new PDF document
  $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
  
  // set document information
  $pdf-&gt;SetCreator(PDF_CREATOR);
  $pdf-&gt;SetAuthor('Nicola Asuni');
  $pdf-&gt;SetTitle('TCPDF Example 004');
  $pdf-&gt;SetSubject('TCPDF Tutorial');
  $pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');
  
  // set default header data
  $pdf-&gt;SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 004', PDF_HEADER_STRING);
  
  // set header and footer fonts
  $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
  $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
  
  // 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 (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('times', '', 11);
  
  // add a page
  $pdf-&gt;AddPage();
  
  // MultiCell($w, $h, $txt, $border=0, $align='J', $fill=0, $ln=1, $x='', $y='', $reseth=true, $stretch=0, $ishtml=false, $autopadding=true, $maxh=0)
  
  // test Cell stretching
  while($row = mysql_fetch_array($sql)){
      $pdf-&gt;MultiCell(55, 5, $row['ref_code'], 1, 'L', 0, 0, '', '', true);
      $pdf-&gt;MultiCell(55, 5, $row['video_title'], 1, 'L', 0, 0, '', '', true);
      $pdf-&gt;Ln();
  }
  
  $pdf-&gt;AddPage();
  
  // example using general stretching and spacing
  
  
  
  // ---------------------------------------------------------
  
  //Close and output PDF document
  $pdf-&gt;Output('example_004.pdf', 'I');
  
  //============================================================+
  // END OF FILE
  //============================================================+
  </code></pre>
  
  <p><a href="https://www.facebook.com/photo.php?fbid=786137934733802&amp;set=a.100403239973945.765.100000128079989&amp;type=1&amp;theater" rel="nofollow">The photo of the table can be seen here.</a></p>