diff --git a/lpdf.php b/lpdf.php index 424b81a..4f41b71 100644 --- a/lpdf.php +++ b/lpdf.php @@ -557,18 +557,24 @@ class lpdf { $this->yloc-=$height['tabledata']; $xpos=$xpos_of_table; + $extralinestomove=0; for($c=0;$c<$table_cols;$c++) { $width=$table['widths'][$c]; - $h=0; - for($h=1; $h<5;$h++) { - $notfit=pdf_show_boxed($this->pdf,$dataline[$c],$this->loc($xpos+$table_padding),$this->loc($this->yloc),$this->loc($width-2*$table_padding),$this->loc($height['tabledata'])*$h, $table['dataalign'][$c],null); + $textstr=$dataline[$c]; + $h=1; + do + { + //get rid of any leading \n's they cause havok + if($textstr[0]=="\n") $textstr=substr($textstr,1); + $notfit=pdf_show_boxed($this->pdf,$textstr,$this->loc($xpos+$table_padding),$this->loc($this->yloc-($h-1)*$height['tabledata']),$this->loc($width-2*$table_padding),$this->loc($height['tabledata']),$table['dataalign'][$c],null); + $h++; + $textstr=substr($textstr,-$notfit); + if($allow_multiline == false) break; // default behaviour, don't try multi lines - if($notfit == 0) { - break; - } - $this->yloc -= $height['tabledata']; - } + }while($notfit); + + if($h-2>$extralinestomove) $extralinestomove=$h-2; //put a little "..." at the end of the field if($notfit) @@ -580,6 +586,8 @@ class lpdf $xpos+=$width; } + $this->yloc -= $height['tabledata']*$extralinestomove; + //draw the line below the table data) pdf_moveto($this->pdf,$this->loc($xpos_of_table),$this->loc($this->yloc));