From b3f4c1130f3e85c2e1ce235cf18035dc70193c53 Mon Sep 17 00:00:00 2001 From: amielboim Date: Mon, 28 Mar 2016 14:04:27 +0300 Subject: [PATCH] Improve myPdf class to RTL languages --- _class/myPdf.class.php | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/_class/myPdf.class.php b/_class/myPdf.class.php index d31ce9b4..3af3e7ee 100644 --- a/_class/myPdf.class.php +++ b/_class/myPdf.class.php @@ -576,47 +576,62 @@ public function setRotation($angle, $xC=null, $yC=null) /** * we redifine the original SetX method, because we don't want the automatic treatment. - * It is HTML2PDF that make the treatment + * It is HTML2PDF that make the treatment. + * If language is RTL direction this method will call to parent (TCPDF class). * * @param float $x - * @param boolean $rtloff NOT USED + * @param boolean $rtloff * @access public */ public function SetX($x, $rtloff=false) { - $this->x=$x; + if (!$rtloff AND $this->rtl) { + parent::SetX($x, $rtloff); + } else { + $this->x=$x; + } } /** * we redifine the original SetY method, because we don't want the automatic treatment. - * It is HTML2PDF that make the treatment + * It is HTML2PDF that make the treatment. + * If language is RTL direction this method will call to parent (TCPDF class). * * @param float $y * @param boolean $resetx Reset the X position - * @param boolean $rtloff NOT USED + * @param boolean $rtloff * @access public */ public function SetY($y, $resetx=true, $rtloff=false) { - if ($resetx) - $this->x=$this->lMargin; + if (!$rtloff AND $this->rtl) { + parent::SetY($y, $resetx, $rtloff); + } else { + if ($resetx) + $this->x=$this->lMargin; - $this->y=$y; + $this->y=$y; + } } /** * we redifine the original SetXY method, because we don't want the automatic treatment. - * It is HTML2PDF that make the treatment + * It is HTML2PDF that make the treatment. + * If language is RTL direction this method will call to parent (TCPDF class). * * @param integer $x * @param integer $y - * @param boolean $rtloff NOT USED + * @param boolean $rtloff * @access public */ public function SetXY($x, $y, $rtloff=false) { - $this->x=$x; - $this->y=$y; + if (!$rtloff AND $this->rtl) { + parent::SetXY($x, $y, $rtloff); + } else { + $this->x=$x; + $this->y=$y; + } } /**