title: Need to align top and wrap text while using FPDF?
body: <p>Hi i am using fpdf to generate pdf automatically to read data from sql >since most of the content pulled from db it a paragraph of around 300words ..it not being wrapped by the columns i made in fpdf..it just goes as a single line..Is there any way to wrap the text with in the column .output image is attached at the end of the post..One more questain,how can i send this pdf to email automatically</p>
  
  <pre><code>   &lt;?php
  
  require('fpdf.php');
  
  //Connect to your database
  $link = mysql_connect('www.xxxxxxx.co.uk', 'xxxxxxx', 'xxxxxx');
  if (!$link) {
      die('Could not connect: ' . mysql_error());
  }
  
  //Create new pdf file
  $pdf=new FPDF();
  
  //Open file
  $pdf-&gt;Open();
  
  //Disable automatic page break
  $pdf-&gt;SetAutoPageBreak(true);
  
  //Add first page
  $pdf-&gt;AddPage();
  
  //set initial y axis position per page
  $y_axis_initial = 25;
  
  //print column titles for the actual page
  $pdf-&gt;SetFillColor(232, 232, 232);
  $pdf-&gt;SetFont('Arial', 'B', 12);
  $pdf-&gt;SetY($y_axis_initial);
  $pdf-&gt;SetX(5);
  /*$pdf-&gt;Cell(30, 6, 'CODE', 1, 0, 'L', 1);
  $pdf-&gt;Cell(30, 6, 'NAME', 1, 0, 'L', 1);
  $pdf-&gt;Cell(30, 6, 'PRICE', 1, 0, 'R', 1);*/
  
  $y_axis = $y_axis + $row_height;
  
  
  mysql_select_db("web39-sdasdasd", $link);
  $q = "SELECT qr_topics,start_of,differential_dia,things_not,investigations,risks FROM qr_table";
  $result = mysql_query ($q, $link);
  
  //initialize counter
  $i = 0;
  
  //Set maximum rows per page
  $max = 25;
  
  //Set Row Height
  $row_height = 80;
  $pdf-&gt;Cell(33, 6, '  ', 1, 0, 'L', 1);
  $pdf-&gt;Cell(33, 6, 'Starting off', 1, 0, 'L', 1);
  $pdf-&gt;Cell(33, 6, 'Differential diagnosis', 1, 0, 'L', 1);
  $pdf-&gt;Cell(33, 6, 'Not to miss', 1, 0, 'L', 1);
  $pdf-&gt;Cell(33, 6, 'Investigations', 1, 0, 'L', 1);
  $pdf-&gt;Cell(33, 6, 'Risks', 1, 0, 'L', 1);
  
  $y_axis =(35);
  
  while($row = mysql_fetch_array($result))
  {
  
  
      $cad = $row['qr_topics'];
      $pad = $row['start_of'];
      $nad = $row['differential_dia'];
      $vad = $row['things_not'];
      $sad = $row['investigations'];
      $tad = $row['risks'];
  
      $pdf-&gt;SetY($y_axis);
      $pdf-&gt;SetX(5);
      $pdf-&gt;Cell(33,80,$cad,1,0,'L',1);
      $pdf-&gt;Cell(33,80,$pad,1,0,'L',1);
      $pdf-&gt;Cell(33,80,$nad,1,0,'L',1);
      $pdf-&gt;Cell(33,80,$vad,1,0,'L',1);
      $pdf-&gt;Cell(33,80,$sad,1,0,'L',1);
      $pdf-&gt;Cell(33,80,$tad,1,0,'L',1);
  
      //Go to next row
      $y_axis = $y_axis + $row_height;
      $i = $i + 1;
  }
  
  mysql_close($link);
  
  //Send file
  $pdf-&gt;Output();
  ?&gt;
  </code></pre>
  
  <p>The output is shown below</p>
  
  <p><img src="https://i.stack.imgur.com/QtQYh.jpg" alt="enter image description here"></p>