title: Word wrap using FPDF in table cell
body: <p>I am having a problem getting text to word wrap using FPDF.  The only row I need to wrap is product_description which you can see in my code below.  I have tried MultiCell without success.</p>
  
  <p>Can anyone help?</p>
  
  <p>Thanks.</p>
  
  <pre><code>function CreatePDFQuote($var)
  {
      require_once(DIR.'/classes/fpdf/fpdf.php');
      require_once(DIR.'/classes/fpdi/fpdi.php');
  
      $pdf = new FPDI();
      $pdf-&gt;AddPage();
      $pound_sign = html_entity_decode("&amp;#xA3;", ENT_COMPAT, 'ISO-8859-1');
  
      /* Image &amp; address */
      $pdf-&gt;Image('../images/headsup_pdf.jpg', 8,8);
      $pdf-&gt;Cell(120,5,"",0,0,'',false);
      $pdf-&gt;SetFillColor(255, 255, 255);
      $pdf-&gt;SetFont('Arial','B',12);
      $pdf-&gt;Cell(40,5,"Company Limited",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(120,5,"",0,0,'',false);
      $pdf-&gt;SetFont('Arial','B',9);
      $pdf-&gt;Cell(40,5,"Address 1",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(120,5,"",0,0,'',false);
      $pdf-&gt;Cell(40,5,"Tel: 09800 000 123",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(120,5,"",0,0,'',false);
      $pdf-&gt;Cell(40,5,"sales@domain.com",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
  
      /* Invoice number &amp; Date */
      $pdf-&gt;SetDrawColor(218, 218, 218);
      $pdf-&gt;SetFillColor(241, 241, 241);
      $pdf-&gt;SetFont('Arial','B',9);
      $pdf-&gt;Cell(50,5,"Quote Number",1,0,'',true);
      $pdf-&gt;Cell(60,5,"Date",1,0,'',true);
      $pdf-&gt;Ln();
      $pdf-&gt;SetFillColor(255, 255, 255);
      $pdf-&gt;SetFont('Arial','',9);
      $pdf-&gt;Cell(50,5,$var['pdf_quote_id'],1,0,'',true);
      $pdf-&gt;Cell(60,5,date('j/n/Y', strtotime($var['pdf_date'])),1,0,'',true);
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
  
      /* Company, contact &amp; telephone */
      $pdf-&gt;SetDrawColor(218, 218, 218);
      $pdf-&gt;SetFillColor(241, 241, 241);
      $pdf-&gt;SetFont('Arial','B',9);
      $pdf-&gt;Cell(60,5,"Company",1,0,'',true);
      $pdf-&gt;Cell(60,5,"Contact",1,0,'',true);
      $pdf-&gt;Cell(50,5,"Telephone",1,0,'',true);
      $pdf-&gt;Ln();
      $pdf-&gt;SetFillColor(255, 255, 255);
      $pdf-&gt;SetFont('Arial','',9);
      $pdf-&gt;Cell(60,5,$var['pdf_company_name'],1,0,'',true);
      $pdf-&gt;Cell(60,5,$var['pdf_first_name'].' '.$var['pdf_last_name'],1,0,'',true);
      $pdf-&gt;Cell(50,5,$var['pdf_telephone'],1,0,'',true);
      $pdf-&gt;Ln();
      $pdf-&gt;Ln();
  
      $page_height = 286.93; // page height
      $height_of_cell = 8;
      $offset = 35;
      $bottom_margin = 30;
  
      foreach($var['pdf_products'] as $product)
      {
          $space_left = $page_height - ($pdf-&gt;GetY() + $bottom_margin + $offset); // space left on page
  
          if($height_of_cell &gt; $space_left)
          {
              $pdf-&gt;AddPage();
  
              /* Image &amp; address */
              $pdf-&gt;Cell(120,5,$pdf-&gt;Image('../images/headsup_pdf.jpg',4,8),0,0,'',false);
              $pdf-&gt;SetFillColor(255, 255, 255);
              $pdf-&gt;SetFont('Arial','B',12);
              $pdf-&gt;Cell(40,5,"Heads Up PGB Limited",0,0,'',false);
              $pdf-&gt;Ln();
              $pdf-&gt;Cell(120,5,"",0,0,'',false);
              $pdf-&gt;SetFont('Arial','B',9);
              $pdf-&gt;Cell(40,5,"13 Church Hill, Epping, Essex, CM16 4RA",0,0,'',false);
              $pdf-&gt;Ln();
              $pdf-&gt;Cell(120,5,"",0,0,'',false);
              $pdf-&gt;Cell(40,5,"Tel: 0203 058 2320",0,0,'',false);
              $pdf-&gt;Ln();
              $pdf-&gt;Cell(120,5,"",0,0,'',false);
              $pdf-&gt;Cell(40,5,"sales@domain.com",0,0,'',false);
              $pdf-&gt;Ln();
              $pdf-&gt;Ln();
              $pdf-&gt;Ln();
              $pdf-&gt;Ln();
              $pdf-&gt;Ln();
          }
  
          // Product code
          $pdf-&gt;SetDrawColor(218, 218, 218);
          $pdf-&gt;SetFillColor(241, 241, 241);
          $pdf-&gt;SetFont('Arial','B',9);
          $pdf-&gt;Cell(50,8,"Product Code",1,0,'',true);
          $pdf-&gt;Cell(60,8,$product['product_code'],1,0,'',true);
          $pdf-&gt;Cell(60,8, $pdf-&gt;Image(SITEURL.'/'.$product['product_image'], $pdf-&gt;GetX(), $pdf-&gt;GetY(), 33.78),0,0,0,false);
          $pdf-&gt;Ln();
  
          $pdf-&gt;SetFillColor(255, 255, 255);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(110,8,$product['product_name'],LR,0,'',true);
          $pdf-&gt;Ln();
  
          $pdf-&gt;SetFillColor(255, 255, 255);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(110,5,$product['product_description'],LR,0,'',true);
          $pdf-&gt;Ln();
  
          $pdf-&gt;SetFillColor(255, 255, 255);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(110,8,"Price includes a ".$product['logo_colours']." colour print.",LRB,0,'',true);
          $pdf-&gt;Ln();
  
          $pdf-&gt;SetFillColor(241, 241, 241);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(50,8,$product['quantity'].' @ '.$pound_sign.$product['unit_cost'].' each',1,0,'',true);
          $pdf-&gt;Cell(60,8,$pound_sign.$product['line_total'],1,0,'',true);
          $pdf-&gt;Ln();
  
          $pdf-&gt;SetFillColor(255, 255, 255);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(50,8,'1 x Origination',1,0,'',true);
          $pdf-&gt;Cell(60,8,$pound_sign.$product['origination'],1,0,'',true);
          $pdf-&gt;Ln();
  
          if($product['extra_costs'] &gt; 0)
          {
              $pdf-&gt;SetFillColor(241, 241, 241);
              $pdf-&gt;SetFont('Arial','',9);
              $pdf-&gt;Cell(50,8,'Extra Costs',1,0,'',true);
              $pdf-&gt;Cell(60,8,$pound_sign.$product['extra_costs'],1,0,'',true);
              $pdf-&gt;Ln();
          }
  
          $pdf-&gt;SetFillColor(241, 241, 241);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(50,8,'Delivery to 1 UK Address',1,0,'',true);
          $pdf-&gt;Cell(60,8,$pound_sign.$product['delivery_charge'],1,0,'',true);
          $pdf-&gt;Ln();
  
          $vat = ($product['line_total'] + $product['origination'] + $product['delivery_charge'] + $product['extra_costs']) * 0.2;
          $pdf-&gt;SetFillColor(255, 255, 255);
          $pdf-&gt;SetFont('Arial','',9);
          $pdf-&gt;Cell(50,8,'VAT 20%',1,0,'',true);
          $pdf-&gt;Cell(60,8,$pound_sign.number_format($vat, 2),1,0,'',true);
          $pdf-&gt;Ln();
  
          $total = ($product['line_total'] + $product['origination'] + $product['delivery_charge'] + $product['extra_costs'] + $vat);
          $pdf-&gt;SetFillColor(241, 241, 241);
          $pdf-&gt;SetFont('Arial','B',9);
          $pdf-&gt;Cell(50,8,'Total',1,0,'',true);
          $pdf-&gt;Cell(60,8,$pound_sign.number_format($total, 2),1,0,'',true);
          $pdf-&gt;Ln();
          $pdf-&gt;Ln();
      }
  
      $pdf-&gt;SetFillColor(255, 255, 255);
      $pdf-&gt;SetFont('Arial','',9);
      $pdf-&gt;Cell(110,10,"Thank you for your quote request.  Please do not hesitate to contact us, should you have any further requirements.",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(110,5,"Kind Regards,",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(110,5,"Team",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(110,5,"020 3058 2320",0,0,'',false);
      $pdf-&gt;Ln();
      $pdf-&gt;Cell(110,5,"sales@domain.com",0,0,'',false);
      $pdf-&gt;Ln();
  
      /* Save PDF file */
      $pdf_filename = str_replace(' ', '', $var['pdf_id']).'_'.strtotime($var['pdf_date']).'_'.uniqid().'.pdf';
      $pdf-&gt;Output(DIR.'/'.$var['pdf_folder'].'/'.$pdf_filename, 'F');
  
      return $pdf_filename;
  }
  </code></pre>