From: <Ex...@us...> - 2012-03-08 10:03:02
|
Revision: 5061 http://web-erp.svn.sourceforge.net/web-erp/?rev=5061&view=rev Author: ExsonQu Date: 2012-03-08 10:02:55 +0000 (Thu, 08 Mar 2012) Log Message: ----------- 8/3/2012 Vitaly fixed for wrong word width calculated in class.pdf.php Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2012-03-08 09:20:47 UTC (rev 5060) +++ trunk/includes/class.pdf.php 2012-03-08 10:02:55 UTC (rev 5061) @@ -70,11 +70,11 @@ TCPDF::Line ($x1,$this->h-$y1,$x2,$this->h-$y2,$style); } - function addText($xb,$yb,$size,$text)//,$angle=0,$wordSpaceAdjust=0) + function addText($xb,$YPos,$size,$text)//,$angle=0,$wordSpaceAdjust=0) { // Javier $text = html_entity_decode($text); $this->SetFontSize($size); - $this->Text($xb, $this->h-$yb, $text); + $this->Text($xb, $this->h-$YPos, $text); } function addInfo($label, $value) { @@ -103,8 +103,8 @@ } - function addJpegFromFile($img,$x,$y,$w=0,$h=0){ - $this->Image($img, $x, $this->h-$y-$h, $w, $h); + function addJpegFromFile($img,$XPos,$y,$Width=0,$Height=0){ + $this->Image($img, $XPos, $this->h-$y-$Height, $Width, $Height); } /* @@ -242,36 +242,38 @@ $this->line($XPos, $YPos-$Height, $XPos, $YPos); } - function addTextWrap($x, $yb, $w, $h, $txt, $align='J', $border=0, $fill=0) { - - //$txt = html_entity_decode($txt); - + function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='J', $border=0, $fill=0) { + + /* Returns the balance of the string that could not fit in the width + * XPos = pdf horizontal coordinate + * YPos = pdf vertical coordiante + */ //some special characters are html encoded //this code serves to make them appear human readable in pdf file - $txt = html_entity_decode($txt, ENT_QUOTES, 'UTF-8'); + $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); - $this->x = $x; - $this->y = $this->h - $yb - $h; + $this->x = $XPos; + $this->y = $this->h - $YPos - $Height; - switch($align) { + switch($Align) { case 'right': - $align = 'R'; break; + $Align = 'R'; break; case 'center': - $align = 'C'; break; + $Align = 'C'; break; default: - $align = 'L'; + $Align = 'L'; } - $this->SetFontSize($h); - $cw=&$this->CurrentFont['cw']; - if($w==0) { - $w=$this->w-$this->rMargin-$this->x; + $this->SetFontSize($Height); + + if($Width==0) { + $Width=$this->w-$this->rMargin-$this->x; } - $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; - $s=str_replace("\r",'',$txt); + $wmax=($Width-2*$this->cMargin); + $s=str_replace("\r",'',$Text); $s=str_replace("\n",' ',$s); $s = trim($s).' '; - $nb=strlen($s); + $nb=mb_strlen($s); $b=0; if ($border) { if ($border==1) { @@ -280,19 +282,20 @@ $b2='LR'; } else { $b2=''; - if(is_int(strpos($border,'L'))) { + if(is_int(mb_strpos($border,'L'))) { $b2.='L'; } - if(is_int(strpos($border,'R'))) { + if(is_int(mb_strpos($border,'R'))) { $b2.='R'; } - $b=is_int(strpos($border,'T')) ? $b2.'T' : $b2; + $b=is_int(mb_strpos($border,'T')) ? $b2.'T' : $b2; } } $sep=-1; $i=0; $l= $ls=0; $ns=0; + $cw = $this->GetStringWidth($s, '', '', 0, true); while($i<$nb) { $c=$s{$i}; if($c==' ' AND $i>0) { @@ -318,15 +321,15 @@ } $sep = $i; } else { - if($align=='J') { - $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; + if($Align=='J') { + $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } } - $this->Cell($w,$h,substr($s,0,$sep),$b,2,$align,$fill); + $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); $this->x=$this->lMargin; - return substr($s, $sep); + return mb_substr($s, $sep); } //end function addTextWrap } // end of class This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |