title: create table in pdf with wrap data using fpdf in php
body: <p>I have a problem in creating table structure in pdf using fpdf library. when any data of perticular cell have a long string then the cell data will overlap with other cell data.
  So whole table data has been disordered. then data in pdf will not seem correctly.</p>
  
  <p>any one please help me to create table in pdf auto adjust all cells according to data in cell. </p>
  
  <pre><code>    &lt;?php
  if($_POST['cmbReportType'] == '1')
  {
  $fromdate = date_format(date_create($_POST['txtFromDate']), 'd-M-y');
  $import = ociparse($c, "SELECT 
                              t2.membercardno, (t1.firstname||' '||t1.middlename||' '||t1.lastname) as fullname,
                              t3.description,
                              to_char(t2.startdate,'DD-MON-YY') startdate,
                              to_char(t2.expirydate,'DD-MON-YY') expirydate,
                              t2.ramount,
                              t1.address1,
                              t1.address2
                          FROM 
                              useradmin t1, 
                              userplan t2, 
                              plan t3
                          WHERE 
                              t1.memberid = t2.memberid
                          AND 
                              t2.planid = t3.planid
                          AND 
                              t1.branchid = 3
                          AND 
                              t2.startdate &gt;= '$fromdate'
                          ORDER BY t2.membercardno");
  
  
  OCIExecute($import);
  $k=0;
  while(OCIFetch($import))
  {
      $a[$k]['membercardno'] = ociresult($import,"MEMBERCARDNO");
      $a[$k]['fullname']   = ociresult($import,"FULLNAME");
      $a[$k]['description'] = ociresult($import,"DESCRIPTION");
      $a[$k]['startdate']  = ociresult($import, "STARTDATE");
      $a[$k]['expirydate'] = ociresult($import, "EXPIRYDATE");
      $a[$k]['ramount']  =  ociresult($import, "RAMOUNT");
      $a[$k]['address1'] = ociresult($import, "ADDRESS1");
      $a[$k]['address2'] = ociresult($import, "ADDRESS2");    
      $k++;
  }
  $resultcount = count($a);
  
  elseif($_POST['rdbReportFormat'] == 'pdf')
  {
  /***This report view in tabular format.****/
      $pdf=new FPDF();
  
  $pdf-&gt;AddPage();
  $reportdate = date('d-m-Y');
  $filename = $reportdate.'_report.pdf';
  $pdf-&gt;SetFillColor(255,0,0);
  $pdf-&gt;SetTextColor(255);
  $pdf-&gt;SetDrawColor(128,0,0);
  $pdf-&gt;SetLineWidth(.3);
  $pdf-&gt;SetFont('Arial', 'B', 6);
  // Header
  $header=array('Member Card No','Full Name','Description', 'Start Date', 'Expiry Date', 'ramount', 'Address1', 'Address2');
  $w = array(25, 35, 35, 15, 18, 15, 30, 30);
  for($i=0;$i&lt;count($header); $i++)
      $pdf-&gt;Cell($w[$i],7, $header[$i], 1, 0, 'L', true);
  
  $pdf-&gt;Ln();
  
  // Reset colour set for data 
  $pdf-&gt;SetFillColor(224,235,255);
  $pdf-&gt;SetTextColor(0);
  $pdf-&gt;SetFont('courier','',7);
  $fill=false;
  for($i=0;$i&lt;$resultcount;$i++)
  {
      $height =6;
      $pdf-&gt;Cell($w[0], '$height', $a[$i]['membercardno'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[1], '$height', $a[$i]['fullname'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[2], '$height', $a[$i]['description'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[3], '$height', $a[$i]['startdate'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[4], '$height', $a[$i]['expirydate'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[5], '$height', $a[$i]['ramount'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[5], '$height', $a[$i]['address1'], '1', '0', 'L', $fill);
      $pdf-&gt;Cell($w[5], '$height', $a[$i]['address2'], '1', '0', 'L', $fill);
      $pdf-&gt;Ln();
      $fill = !$fill;
  
  }   
  $pdf-&gt;Cell(array_sum($w),0,'','T');
  $pdf-&gt;Output($filename, 'I');
  }
  }   
  ?&gt;
  </code></pre>