From: <Ex...@us...> - 2012-02-20 07:43:45
|
Revision: 4934 http://web-erp.svn.sourceforge.net/web-erp/?rev=4934&view=rev Author: ExsonQu Date: 2012-02-20 07:43:39 +0000 (Mon, 20 Feb 2012) Log Message: ----------- Replace the file back since the revised one will lead to some Chinese Characters missing Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2012-02-20 07:22:30 UTC (rev 4933) +++ trunk/includes/class.pdf.php 2012-02-20 07:43:39 UTC (rev 4934) @@ -70,11 +70,11 @@ TCPDF::Line ($x1,$this->h-$y1,$x2,$this->h-$y2,$style); } - function addText($xb,$YPos,$size,$text)//,$angle=0,$wordSpaceAdjust=0) + function addText($xb,$yb,$size,$text)//,$angle=0,$wordSpaceAdjust=0) { // Javier $text = html_entity_decode($text); $this->SetFontSize($size); - $this->Text($xb, $this->h-$YPos, $text); + $this->Text($xb, $this->h-$yb, $text); } function addInfo($label, $value) { @@ -103,8 +103,8 @@ } - function addJpegFromFile($img,$XPos,$y,$Width=0,$Height=0){ - $this->Image($img, $XPos, $this->h-$y-$Height, $Width, $Height); + function addJpegFromFile($img,$x,$y,$w=0,$h=0){ + $this->Image($img, $x, $this->h-$y-$h, $w, $h); } /* @@ -242,38 +242,36 @@ $this->line($XPos, $YPos-$Height, $XPos, $YPos); } - 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 - */ + function addTextWrap($x, $yb, $w, $h, $txt, $align='J', $border=0, $fill=0) { + + //$txt = html_entity_decode($txt); + //some special characters are html encoded //this code serves to make them appear human readable in pdf file - $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); + $txt = html_entity_decode($txt, ENT_QUOTES, 'UTF-8'); - $this->x = $XPos; - $this->y = $this->h - $YPos - $Height; + $this->x = $x; + $this->y = $this->h - $yb - $h; - 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($Height); - - if($Width==0) { - $Width=$this->w-$this->rMargin-$this->x; + $this->SetFontSize($h); + $cw=&$this->CurrentFont['cw']; + if($w==0) { + $w=$this->w-$this->rMargin-$this->x; } - $wmax=($Width-2*$this->cMargin); - $s=str_replace("\r",'',$Text); + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); $s=str_replace("\n",' ',$s); $s = trim($s).' '; - $nb=mb_strlen($s); + $nb=strlen($s); $b=0; if ($border) { if ($border==1) { @@ -282,20 +280,19 @@ $b2='LR'; } else { $b2=''; - if(is_int(mb_strpos($border,'L'))) { + if(is_int(strpos($border,'L'))) { $b2.='L'; } - if(is_int(mb_strpos($border,'R'))) { + if(is_int(strpos($border,'R'))) { $b2.='R'; } - $b=is_int(mb_strpos($border,'T')) ? $b2.'T' : $b2; + $b=is_int(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) { @@ -321,15 +318,15 @@ } $sep = $i; } else { - if($Align=='J') { - $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; + if($align=='J') { + $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } } - $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); + $this->Cell($w,$h,substr($s,0,$sep),$b,2,$align,$fill); $this->x=$this->lMargin; - return mb_substr($s, $sep); + return 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. |
From: <Ex...@us...> - 2012-02-20 07:43:48
|
Revision: 4934 http://web-erp.svn.sourceforge.net/web-erp/?rev=4934&view=rev Author: ExsonQu Date: 2012-02-20 07:43:39 +0000 (Mon, 20 Feb 2012) Log Message: ----------- Replace the file back since the revised one will lead to some Chinese Characters missing Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2012-02-20 07:22:30 UTC (rev 4933) +++ trunk/includes/class.pdf.php 2012-02-20 07:43:39 UTC (rev 4934) @@ -70,11 +70,11 @@ TCPDF::Line ($x1,$this->h-$y1,$x2,$this->h-$y2,$style); } - function addText($xb,$YPos,$size,$text)//,$angle=0,$wordSpaceAdjust=0) + function addText($xb,$yb,$size,$text)//,$angle=0,$wordSpaceAdjust=0) { // Javier $text = html_entity_decode($text); $this->SetFontSize($size); - $this->Text($xb, $this->h-$YPos, $text); + $this->Text($xb, $this->h-$yb, $text); } function addInfo($label, $value) { @@ -103,8 +103,8 @@ } - function addJpegFromFile($img,$XPos,$y,$Width=0,$Height=0){ - $this->Image($img, $XPos, $this->h-$y-$Height, $Width, $Height); + function addJpegFromFile($img,$x,$y,$w=0,$h=0){ + $this->Image($img, $x, $this->h-$y-$h, $w, $h); } /* @@ -242,38 +242,36 @@ $this->line($XPos, $YPos-$Height, $XPos, $YPos); } - 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 - */ + function addTextWrap($x, $yb, $w, $h, $txt, $align='J', $border=0, $fill=0) { + + //$txt = html_entity_decode($txt); + //some special characters are html encoded //this code serves to make them appear human readable in pdf file - $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); + $txt = html_entity_decode($txt, ENT_QUOTES, 'UTF-8'); - $this->x = $XPos; - $this->y = $this->h - $YPos - $Height; + $this->x = $x; + $this->y = $this->h - $yb - $h; - 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($Height); - - if($Width==0) { - $Width=$this->w-$this->rMargin-$this->x; + $this->SetFontSize($h); + $cw=&$this->CurrentFont['cw']; + if($w==0) { + $w=$this->w-$this->rMargin-$this->x; } - $wmax=($Width-2*$this->cMargin); - $s=str_replace("\r",'',$Text); + $wmax=($w-2*$this->cMargin)*1000/$this->FontSize; + $s=str_replace("\r",'',$txt); $s=str_replace("\n",' ',$s); $s = trim($s).' '; - $nb=mb_strlen($s); + $nb=strlen($s); $b=0; if ($border) { if ($border==1) { @@ -282,20 +280,19 @@ $b2='LR'; } else { $b2=''; - if(is_int(mb_strpos($border,'L'))) { + if(is_int(strpos($border,'L'))) { $b2.='L'; } - if(is_int(mb_strpos($border,'R'))) { + if(is_int(strpos($border,'R'))) { $b2.='R'; } - $b=is_int(mb_strpos($border,'T')) ? $b2.'T' : $b2; + $b=is_int(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) { @@ -321,15 +318,15 @@ } $sep = $i; } else { - if($Align=='J') { - $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; + if($align=='J') { + $this->ws=($ns>1) ? ($wmax-$ls)/1000*$this->FontSize/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } } - $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); + $this->Cell($w,$h,substr($s,0,$sep),$b,2,$align,$fill); $this->x=$this->lMargin; - return mb_substr($s, $sep); + return 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. |
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. |
From: <Ex...@us...> - 2012-03-08 10:03:06
|
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. |
From: <rc...@us...> - 2014-08-04 20:16:17
|
Revision: 6803 http://sourceforge.net/p/web-erp/reponame/6803 Author: rchacon Date: 2014-08-04 20:16:08 +0000 (Mon, 04 Aug 2014) Log Message: ----------- class.pdf.php: Adds comments and regroups AddText and AddTextWarp. Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2014-08-02 05:07:53 UTC (rev 6802) +++ trunk/includes/class.pdf.php 2014-08-04 20:16:08 UTC (rev 6803) @@ -71,13 +71,103 @@ TCPDF::Line ($x1,$this->h-$y1,$x2,$this->h-$y2,$style); } - function addText($xb,$YPos,$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-$YPos, $text); } + function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='J', $border=0, $fill=0) { + // R&OS version 0.12.2: "addTextWrap function is no more, use addText instead". + /* 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 + $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); + + $this->x = $XPos; + $this->y = $this->h - $YPos - $Height;//RChacon: This -$Height is the difference in yPos between AddText() and AddTextWarp(). + + switch($Align) { + case 'right': + $Align = 'R'; break; + case 'center': + $Align = 'C'; break; + default: + $Align = 'L'; + } + $this->SetFontSize($Height); + + if($Width==0) { + $Width=$this->w-$this->rMargin-$this->x; + } + $wmax=($Width-2*$this->cMargin); + $s=str_replace("\r",'',$Text); + $s=str_replace("\n",' ',$s); + $s = trim($s).' '; + $nb=mb_strlen($s); + $b=0; + if ($border) { + if ($border==1) { + $border='LTRB'; + $b='LRT'; + $b2='LR'; + } else { + $b2=''; + if(is_int(mb_strpos($border,'L'))) { + $b2.='L'; + } + if(is_int(mb_strpos($border,'R'))) { + $b2.='R'; + } + $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) { + $sep=$i; + $ls=$l; + $ns++; + } + if (isset($cw[$i])) { + $l += $cw[$i]; + } + if($l>$wmax){ + break; + } else { + $i++; + } + } + if($sep==-1) { + if($i==0) { + $i++; + } + + if(isset($this->ws) and $this->ws>0) { + $this->ws=0; + $this->_out('0 Tw'); + } + $sep = $i; + } else { + if($Align=='J') { + $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; + $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); + } + } + + $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); + $this->x=$this->lMargin; + return mb_substr($s, $sep); + }// End function addTextWrap. + function addInfo($label, $value) { if ($label == 'Creator') { @@ -239,96 +329,6 @@ $this->partEllipse($XPos+$Width-$RadiusX, $YPos-$Height+$RadiusY, 270, 360, $RadiusX, $RadiusY);// Bottom right corner. } - 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 - $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); - - $this->x = $XPos; - $this->y = $this->h - $YPos - $Height; - - switch($Align) { - case 'right': - $Align = 'R'; break; - case 'center': - $Align = 'C'; break; - default: - $Align = 'L'; - } - $this->SetFontSize($Height); - - if($Width==0) { - $Width=$this->w-$this->rMargin-$this->x; - } - $wmax=($Width-2*$this->cMargin); - $s=str_replace("\r",'',$Text); - $s=str_replace("\n",' ',$s); - $s = trim($s).' '; - $nb=mb_strlen($s); - $b=0; - if ($border) { - if ($border==1) { - $border='LTRB'; - $b='LRT'; - $b2='LR'; - } else { - $b2=''; - if(is_int(mb_strpos($border,'L'))) { - $b2.='L'; - } - if(is_int(mb_strpos($border,'R'))) { - $b2.='R'; - } - $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) { - $sep=$i; - $ls=$l; - $ns++; - } - if (isset($cw[$i])) { - $l += $cw[$i]; - } - if($l>$wmax){ - break; - } else { - $i++; - } - } - if($sep==-1) { - if($i==0) { - $i++; - } - - if(isset($this->ws) and $this->ws>0) { - $this->ws=0; - $this->_out('0 Tw'); - } - $sep = $i; - } else { - if($Align=='J') { - $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; - $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); - } - } - - $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); - $this->x=$this->lMargin; - return mb_substr($s, $sep); - } //end function addTextWrap - } // end of class } //end if Cpdf class exists already ?> |
From: <rc...@us...> - 2015-02-20 16:12:24
|
Revision: 7160 http://sourceforge.net/p/web-erp/reponame/7160 Author: rchacon Date: 2015-02-20 16:12:16 +0000 (Fri, 20 Feb 2015) Log Message: ----------- Right version. Sorry. Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2015-02-20 16:08:13 UTC (rev 7159) +++ trunk/includes/class.pdf.php 2015-02-20 16:12:16 UTC (rev 7160) @@ -71,90 +71,113 @@ TCPDF::Line ($x1,$this->h-$y1,$x2,$this->h-$y2,$style); } - function addText($xb,$YPos,$size,$text/*,$angle=0,$wordSpaceAdjust=0*/) { + function addText($XPos,$YPos,$fontsize,$text/*,$angle=0,$wordSpaceAdjust=0*/) { + // $XPos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). + // $YPos = cell vertical coordinate from page bottom side to cell top side in dpi (72dpi = 25.4mm). + // $fontsize = font size in dpi (72dpi = 25.4mm). // Javier $text = html_entity_decode($text); - $this->SetFontSize($size);// Public function SetFontSize() in ~/includes/tcpdf/tcpdf.php. - $this->Text($xb, $this->h-$YPos, $text);// Public function Text() in ~/includes/tcpdf/tcpdf.php. + $this->SetFontSize($fontsize);// Public function SetFontSize() in ~/includes/tcpdf/tcpdf.php. + $this->Text($XPos, $this->h-$YPos, $text);// Public function Text() in ~/includes/tcpdf/tcpdf.php. } -//------------------------------------------------------------------------------ -public function addTextWrap($xpos, $ypos, $linewidth, $fontsize, $text, $justification='left', $angle=0, $test=0) { -// Adds text to the page, but ensure that it fits within a certain width. If it does not fit then put in as much as possible, splitting at white space or soft hyphen character and return the remainder. Justification can also be specified for the text. It use UTF-8 encoding. -// $xpos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). -// $ypos = cell vertical coordinate from page bottom side to cell bottom? side in dpi (72dpi = 25.4mm). -// $linewidth = cell (line) width in dpi (72dpi = 25.4mm). -// $fontsize = font size in dpi (72dpi = 25.4mm). -// $text = text to be split in portion to be add to the page and the remainder to be returned. -// $justification = 'left', 'right', 'center', 'centre' or 'full'. -// Ignores $angle and $test. -// @access public. + function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='J', $border=0, $fill=0) { + // R&OS version 0.12.2: "addTextWrap function is no more, use addText instead". + /* Returns the balance of the string that could not fit in the width + // $XPos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). + // $YPos = cell vertical coordinate from page bottom side to cell bottom side in dpi (72dpi = 25.4mm). + */ + //some special characters are html encoded + //this code serves to make them appear human readable in pdf file + $Text = html_entity_decode($Text, ENT_QUOTES, 'UTF-8'); -if($linewidth == 0) { - $linewidth = $this->w -$this->rMargin -$xpos;// Line_width = Page_width - Right_margin - Cell_horizontal_coordinate. -} + $this->x = $XPos; + $this->y = $this->h - $YPos - $Height;//RChacon: This -$Height is the difference in yPos between AddText() and AddTextWarp(). -$this->SetFontSize($fontsize);// Public function SetFontSize() in ~/includes/tcpdf/tcpdf.php. + switch($Align) { + case 'right': + $Align = 'R'; break; + case 'center': + $Align = 'C'; break; + default: + $Align = 'L'; + } + $this->SetFontSize($Height); -$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');// Convert all HTML entities to their applicable characters. + if($Width==0) { + $Width=$this->w-$this->rMargin-$this->x; + } + $wmax=($Width-2*$this->cMargin); + $s=str_replace("\r",'',$Text); + $s=str_replace("\n",' ',$s); + $s = trim($s).' '; + $nb=mb_strlen($s); + $b=0; + if ($border) { + if ($border==1) { + $border='LTRB'; + $b='LRT'; + $b2='LR'; + } else { + $b2=''; + if(is_int(mb_strpos($border,'L'))) { + $b2.='L'; + } + if(is_int(mb_strpos($border,'R'))) { + $b2.='R'; + } + $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};*/ + $c=mb_substr($s, $i, 1, 'UTF-8'); + if($c==' ' AND $i>0) { + $sep=$i; + $ls=$l; + $ns++; + } + if (isset($cw[$i])) { + $l += $cw[$i]; + } + if($l>$wmax){ + break; + } else { + $i++; + } + } + if($sep==-1) { + if($i==0) { + $i++; + } -switch($justification) {// Translate from Pdf-Creator to TCPDF. - case 'left': - $justification = 'L'; break; - case 'right': - $justification = 'R'; break; - case 'center': - $justification = 'C'; break; - case 'centre': - $justification = 'C'; break; - case 'full': - $justification = 'J'; break; - default: - $justification = 'L'; break; -} + if(isset($this->ws) and $this->ws>0) { + $this->ws=0; + $this->_out('0 Tw'); + } + $sep = $i; + } else { + if($Align=='J') { + $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; + $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); + } + } -$this->MultiCell($linewidth, $fontsize, $text, 0, $justification, false, 1, $xpos, $this->h - $ypos - $fontsize);// COMMENT: In "$this->h -$ypos -$fontsize", "-$fontsize" is the difference in the yPos between AddText() and AddTextWarp(). It is better "$this->h -$ypos", but that requires to recode all the pdf generator scripts. -} -//------------------------------------------------------------------------------ -function TextWrap($xpos, $ypos, $linewidth, $fontsize, $text, $justification='left', $angle=0, $test=0) { - // Adds text to the page, but ensure that it fits within a certain width. If it does not fit then put in as much as possible, splitting at white space or soft hyphen character and return the remainder. Justification can also be specified for the text. It use UTF-8 encoding. - // $xpos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). - // $ypos = cell vertical coordinate from page bottom side to cell bottom? side in dpi (72dpi = 25.4mm). - // $linewidth = cell (line) width in dpi (72dpi = 25.4mm). - // $fontsize = font size in dpi (72dpi = 25.4mm). - // $text = text to be split in portion to be add to the page and the remainder to be returned. - // $justification = 'left', 'right', 'center', 'centre' or 'full'. - // Ignores $angle and $test. - // @access public. - if($linewidth == 0) { - $linewidth = $this->w -$this->rMargin -$xpos;// Line_width = Page_width - Right_margin - Cell_horizontal_coordinate. - } - $this->SetFontSize($fontsize);// Public function SetFontSize() in ~/includes/tcpdf/tcpdf.php. - $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');// Convert all HTML entities to their applicable characters. - switch($justification) {// Translate from Pdf-Creator to TCPDF. - case 'left': - $justification = 'L'; break; - case 'right': - $justification = 'R'; break; - case 'center': - $justification = 'C'; break; - case 'centre': - $justification = 'C'; break; - case 'full': - $justification = 'J'; break; - default: - $justification = 'L'; break; - } - $this->MultiCell($linewidth, $fontsize, $text, 0, $justification, false, 1, $xpos, $this->h - $ypos); - return $this->h - $this->y;// yPos is the same as in addText(). -} -//=========================================================================================== + $this->Cell($Width,$Height,mb_substr($s,0,$sep),$b,2,$Align,$fill); + $this->x=$this->lMargin; + return mb_substr($s, $sep); + }// End function addTextWrap. function addInfo($label, $value) { if ($label == 'Creator') { /* Javier: Some scripts set the creator to be WebERP like this $pdf->addInfo('Creator', 'WebERP http://www.weberp.org'); - But the Creator is TCPDF by Nicola Asuni, PDF_CREATOR is defined as 'TCPDF' in ~/includes/tcpdf/config/tcpdfconfig.php + But the Creator is TCPDF by Nicola Asuni, PDF_CREATOR is defined as 'TCPDF' in tcpdf/config/tcpdfconfig.php */ $this->SetCreator(PDF_CREATOR); } if ($label == 'Author') { @@ -175,7 +198,7 @@ } function addJpegFromFile($img,$XPos,$YPos,$Width=0,$Height=0,$Type=''){ - $this->Image($img, $x=$XPos, $y=$this->h-$YPos/*-$Height*/, $w=$Width, $h=$Height,$type=$Type); + $this->Image($img, $x=$XPos, $y=$this->h-$YPos-$Height, $w=$Width, $h=$Height,$type=$Type); } /* |
From: <ex...@us...> - 2016-09-24 10:23:38
|
Revision: 7629 http://sourceforge.net/p/web-erp/reponame/7629 Author: exsonqu Date: 2016-09-24 10:23:35 +0000 (Sat, 24 Sep 2016) Log Message: ----------- 24/09/16 Exson: Fixed the AddTextWrap missing characters errors when there is space and make it more reliable. Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2016-09-21 16:14:21 UTC (rev 7628) +++ trunk/includes/class.pdf.php 2016-09-24 10:23:35 UTC (rev 7629) @@ -120,7 +120,7 @@ $s=str_replace("\r",'',$Text); $s=str_replace("\n",' ',$s); $s = trim($s).' '; - $nb=mb_strlen($s); + $nb=mb_strlen($s,'UTF-8'); $b=0; if ($border) { if ($border==1) { @@ -129,13 +129,13 @@ $b2='LR'; } else { $b2=''; - if(is_int(mb_strpos($border,'L'))) { + if(is_int(mb_strpos($border,'L',0,'UTF-8'))) { $b2.='L'; } - if(is_int(mb_strpos($border,'R'))) { + if(is_int(mb_strpos($border,'R',0,'UTF-8'))) { $b2.='R'; } - $b=is_int(mb_strpos($border,'T')) ? $b2.'T' : $b2; + $b=is_int(mb_strpos($border,'T',0,'UTF-8')) ? $b2.'T' : $b2; } } $sep=-1; @@ -146,7 +146,7 @@ while($i<$nb) { /*$c=$s{$i};*/ $c=mb_substr($s, $i, 1, 'UTF-8'); - if($c==' ' AND $i>0) { + if($c===' ' AND $i>0) { $sep=$i; $ls=$l; $ns++; @@ -169,17 +169,17 @@ $this->ws=0; $this->_out('0 Tw'); } - $sep = $i; } else { if($Align=='J') { $this->ws=($ns>1) ? ($wmax-$ls)/($ns-1) : 0; $this->_out(sprintf('%.3f Tw',$this->ws*$this->k)); } } + $sep = $i; $this->Cell($Width,$Height,mb_substr($s,0,$sep,'UTF-8'),$b,2,$Align,$fill); $this->x=$this->lMargin; - return mb_substr($s, $sep,null,'UTF-8'); + return mb_substr($s, $sep,$nb-$sep,'UTF-8'); }// End function addTextWrap. function addInfo($label, $value) { |
From: <ex...@us...> - 2016-09-24 10:29:43
|
Revision: 7631 http://sourceforge.net/p/web-erp/reponame/7631 Author: exsonqu Date: 2016-09-24 10:29:42 +0000 (Sat, 24 Sep 2016) Log Message: ----------- 24/09/16 Exson: Make Justify feature workable in addTextWrap in class.pdf.php. Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2016-09-24 10:24:36 UTC (rev 7630) +++ trunk/includes/class.pdf.php 2016-09-24 10:29:42 UTC (rev 7631) @@ -80,7 +80,7 @@ $this->Text($XPos, $this->h-$YPos, $text);// Public function Text() in ~/includes/tcpdf/tcpdf.php. } - function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='J', $border=0, $fill=0) { + function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='full', $border=0, $fill=0) { // R&OS version 0.12.2: "addTextWrap function is no more, use addText instead". /* Returns the balance of the string that could not fit in the width */ // $XPos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). |
From: <te...@us...> - 2017-01-25 02:38:38
|
Revision: 7730 http://sourceforge.net/p/web-erp/reponame/7730 Author: tehonu Date: 2017-01-25 02:38:37 +0000 (Wed, 25 Jan 2017) Log Message: ----------- Reverse commit 7631 about text justification Modified Paths: -------------- trunk/includes/class.pdf.php Modified: trunk/includes/class.pdf.php =================================================================== --- trunk/includes/class.pdf.php 2017-01-13 23:46:34 UTC (rev 7729) +++ trunk/includes/class.pdf.php 2017-01-25 02:38:37 UTC (rev 7730) @@ -80,7 +80,7 @@ $this->Text($XPos, $this->h-$YPos, $text);// Public function Text() in ~/includes/tcpdf/tcpdf.php. } - function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='full', $border=0, $fill=0) { + function addTextWrap($XPos, $YPos, $Width, $Height, $Text, $Align='J', $border=0, $fill=0) { // R&OS version 0.12.2: "addTextWrap function is no more, use addText instead". // Adds text to the page and returns the balance of the string that could not fit in the width. // $XPos = cell horizontal coordinate from page left side to cell left side in dpi (72dpi = 25.4mm). |