[0004756] Amounts in words on documents were printed in user language instead of...
[fa-stable.git] / reporting / includes / class.pdf.inc
index 2252c28c86e6dd8c07c68b77e51b5bdc279c0444..fb4cbf62d8f3425611e6718669e776da4e74522e 100644 (file)
@@ -63,9 +63,9 @@ include_once (dirname(__FILE__).'/fpdi/fpdi.php');
 
 class Cpdf extends FPDI {
 
-       function Cpdf($pageSize='A4', $lang=null, $pageOrientation='P')
+       function __construct($pageSize='A4', $lang=null, $pageOrientation='P')
        {
-               $this->TCPDF($pageOrientation, 'pt', $pageSize);//, $uni, $enc);
+               parent::__construct($pageOrientation, 'pt', $pageSize);//, $uni, $enc);
                $this->SetLang($lang);
                $this->setPrintHeader(false);
                $this->setPrintFooter(false);
@@ -83,6 +83,8 @@ class Cpdf extends FPDI {
 
                if (!$code)
                        $code = $dflt_lang;
+               else
+                       install_hooks($code);
 
                $lang = array_search_value($code, $installed_languages, 'code');
                $GetText->set_language($lang['code'], strtoupper($lang['encoding']));
@@ -120,7 +122,6 @@ class Cpdf extends FPDI {
                $this->FontFamily = 'helvetica';
                $this->FontStyle = '';
                $this->FontSizePt = 12;
-//             $this->utf8Bidi(array(""));
        }
 
 
@@ -307,20 +308,30 @@ class Cpdf extends FPDI {
                                $align = 'J';
                }
                else
-                       $align = 'R';
+               {
+                       if ($align == 'right')
+                               $align = 'R';// This may need to be 'L'
+                       elseif ($align == 'left')
+                               $align = 'R';
+                       elseif ($align == 'center')
+                               $align = 'C';
+                       elseif ($align == 'justify')
+                               $align = 'J';
+               }
 
+               $txt = parent::unhtmlentities($txt);
                // If horizontal scaling was requested, check to see if we're trying to scale
                // too much.  If so, cut back string first and then scale it.
                $maxScaleFactor = 1.4;
                if ($stretch == 1 || $stretch == 2)
-               $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak);
+                       $txt = $this->calcTextWrap($txt, $w * $maxScaleFactor, $spacebreak);
                // Wrap text if stretching isn't turned on
                else
-               $txt = $this->calcTextWrap($txt, $w, $spacebreak);
+                       $txt = $this->calcTextWrap($txt, $w, $spacebreak);
                $ret = $txt[1];
                $txt = $txt[0];
                $this->SetXY($xb, $this->h - $yb - $h);
-               $txt = parent::unhtmlentities($txt);
+
                if ($this->isunicode && $this->encoding != "UTF-8")
                        $txt = iconv($this->encoding, "UTF-8", $txt);
                $this->Cell($w, $h, $txt, $border, 0, $align, $fill, $link, $stretch);