Advertisement
michaelyuen

FPDF wrap text

Feb 9th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. function vcell($c_width,$c_height,$x_axis,$text) {
  2. $w_w=$c_height/3;
  3. $w_w_1=$w_w+2;
  4. $w_w1=$w_w+$w_w+$w_w+3;
  5. // $w_w2=$w_w+$w_w+$w_w+$w_w+3; // for 3 rows wrap
  6. $len = strlen($text); // check the length of the cell and splits the text into 7 character each and saves in a array
  7. if ($len>7) {
  8.     $w_text=str_split($text,7);
  9.     // splits the text into length of 7 and saves in a array since we need wrap cell of two cell we took $w_text[0], $w_text[1] alone.
  10.     // if we need wrap cell of 3 row then we can go for $w_text[0],$w_text[1],$w_text[2]
  11.     $this->SetX($x_axis);
  12.     $this->Cell($c_width,$w_w_1,$w_text[0],'','','');
  13.     $this->SetX($x_axis);
  14.     $this->Cell($c_width,$w_w1,$w_text[1],'','','');
  15.     //$this->SetX($x_axis);
  16.     // $this->Cell($c_width,$w_w2,$w_text[2],'','','');
  17.     // for 3 rows wrap but increase the $c_height it is very important.
  18.     $this->SetX($x_axis);
  19.     $this->Cell($c_width,$c_height,'','LTRB',0,'L',0);
  20. } else{
  21.   $this->SetX($x_axis);
  22.   $this->Cell($c_width,$c_height,$text,'LTRB',0,'L',0);}
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement