Bug 4987: In rtl languages, text aligned centered is printed aligned right in PDF...
authorJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 17 Aug 2019 14:59:41 +0000 (16:59 +0200)
committerJoe Hunt <joe.hunt.consulting@gmail.com>
Sat, 17 Aug 2019 14:59:41 +0000 (16:59 +0200)
reporting/includes/class.pdf.inc

index ab76ab46ed20fb3311ef59e971682608a97b64ae..4f34ab7d2c99c1432f387c116119f2944b47b63f 100644 (file)
@@ -306,17 +306,26 @@ 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);