1 (edited by rafat 08/14/2019 10:59:57 am)

Topic: Arabic RTL PDF Reports

Hi

Using Arabic as the default language and using the right translation files all seem to be working fine. One big issue I faced is with the reports( i.e sales invoice, remittance..etc). The report defaults to right justified fields and there is no way for me to find out how to put it into Center Justified (for example).

I attach an example of a sales invoice where it clearly shows the middle part (Sales Person, Due Date ..etc) as right justified while the English version is centered.

Where to look into this? It seems to me that header2 has no effect on the text placement  if the chosen language is Arabic (RTL).

Appreciate your help.

Post's attachments

rep107arabic.pdf 517.3 kb, 13 downloads since 2019-08-14 

You don't have the permssions to download the attachments of this post.

Re: Arabic RTL PDF Reports

Documents in LTR are not centered, the Company name, email etc is aligned left, it is a mirror image of  the pdf you have attached.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

3 (edited by rafat 08/14/2019 01:33:26 pm)

Re: Arabic RTL PDF Reports

Not all the report in LTR is left aligned.  The middle part (Between the Company Name and email ..etc and the Bill of Material Details) Is what is called Auxiliary document information is centered as described  in header2.inc

     // Auxiliary document information
        $col = $this->leftMargin;
        foreach($aux_info as $info_header => $info_content)
        {

            $this->row = $iline2 - $this->lineHeight - 1;
            $this->TextWrap($col, $this->row, $width, $info_header, 'C');
            $this->row = $iline3 - $this->lineHeight - 1;
            $this->TextWrap($col, $this->row, $width, $info_content, 'C');
            $col += $width;
        }

The TextWrap(.....$info_header, 'C') means centered. If I change the 'C' to 'L' it goes left or 'R' it goes right.. only if the language is NOT RTL. If the language is English then it behaves according to the choice I made. Arabic always right aligned.

There must be a catch somewhere ..

4 (edited by poncho1234 08/14/2019 04:55:40 pm)

Re: Arabic RTL PDF Reports

@Rafat, Look at a LTR report in the mirror, take a pic; then compare it with your RTL report, highlight differences and post both pics



Note that the FA version of TCPDF is quite dated, there may well be RTL bugs in previous versions. Maybe try the latest version - TCPDF github tcpdf.php, but this may give you more problems than are resolved. But if it does fix the problem at least you know there is a fix - then compare old and new versions. Remember to rename the original tcpdf.php version.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Arabic RTL PDF Reports

@rafat you can try on this new reporting folder

https://frontaccounting.com/punbb/viewt … 223#p35223

www.boxygen.pk

Re: Arabic RTL PDF Reports

Thanks guys,

@boxygen I tried with the new reporting folder but no luck. Same issue.
@poncho1234 I am attaching the same report (rep107) both when English is selected and when Arabic is selected. I highlighted the difference in yellow.

Post's attachments

rep107english1.pdf 51.6 kb, 8 downloads since 2019-08-15 

You don't have the permssions to download the attachments of this post.

7 (edited by rafat 08/15/2019 09:40:29 am)

Re: Arabic RTL PDF Reports

The Arabic file.

Please look at the footer as well..

Post's attachments

rep107arabic1.pdf 482.2 kb, 4 downloads since 2019-08-15 

You don't have the permssions to download the attachments of this post.

8 (edited by poncho1234 08/15/2019 03:57:23 pm)

Re: Arabic RTL PDF Reports

1. Are you sure you only have one copy of header2.php(Check in the company folder)



2. Tracing the Textwrap function back to getCellCode:-

File: \reporting\includes\tcpdf.php

2993:                 if ($align == 'L') {
2994:                     if ($this->rtl) {
2995:                         $dx = $w - $width - $this->cMargin;
2996:                     } else {
2997:                         $dx = $this->cMargin;
2998:                     }
2999:                 } elseif ($align == 'R') {
3000:                     if ($this->rtl) {
3001:                         $dx = $this->cMargin;
3002:                     } else {
3003:                         $dx = $w - $width - $this->cMargin;
3004:                     }
3005:                 } elseif ($align == 'C') {
3006:                     $dx = ($w - $width) / 2;
3007:                 } elseif ($align == 'J') {
3008:                     if ($this->rtl) {
3009:                         $dx = $w - $width - $this->cMargin;
3010:                     } else {
3011:                         $dx = $this->cMargin;
3012:                     }

Option 'C' does not have a if ($this->rtl) statement so 'C' should have no difference in RTL or LTR

So 2a. Logout, Delete all cache in company folder, delete browser cache(Pref change browser) log back in.

2.b In function Textwrap  a function addTextWrap is called, part of function below:-

File: \reporting\includes\class.pdf.inc

294:     function addTextWrap($xb, $yb, $w, $h, $txt, $align='left', $border=0, $fill=0, $link = NULL, $stretch = 1, $spacebreak=false)
295:     {
296:         $ret = "";
297:         if (!$this->rtl)
298:         {
299:             if ($align == 'right')
300:                 $align = 'R';
301:             elseif ($align == 'left')
302:                 $align = 'L';
303:             elseif ($align == 'center')
304:                 $align = 'C';
305:             elseif ($align == 'justify')
306:                 $align = 'J';
307:         }
308:         else
309:             $align = 'R';

this seems to be expecting the $align variable to be either 'right', 'left', 'justify', 'center'; not R, L, J, or C.

So in header2.php try this:-

$this->TextWrap($col, $this->row, $width, $info_header, 'center');

Delete cache etc

Post back results please

Edit it also states that if rtl everything will be R so try changing the else part to this:-

297:         if (!$this->rtl)
298:         {
299:             if ($align == 'right')
300:                 $align = 'R';
301:             elseif ($align == 'left')
302:                 $align = 'L';
303:             elseif ($align == 'center')
304:                 $align = 'C';
305:             elseif ($align == 'justify')
306:                 $align = 'J';
307:         }
308:         else
            {
                 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';
             }

You may need to change
if ($align == 'right')
    $align = 'R';
to
if ($align == 'right')
    $align = 'L';

Note you will need to use:-

$this->TextWrap($col, $this->row, $width, $info_header, 'center');

in header2.php for this to work

Also this will affect all ten of the print documents please check all of them: Please pay special attention to Report 108 (Print statements) As Textwrap is called an additional two times.

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Arabic RTL PDF Reports

@poncho1234

Give me some time to experiment this... as we are touching tcpdf core .. which (supposedly) is very stable and is working OK for all.

I will come back to you soon.

Thx.

Re: Arabic RTL PDF Reports

@rafat, your not touching tcpdf core, your editing \reporting\includes\class.pdf.inc

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

11 (edited by rafat 08/16/2019 02:05:30 am)

Re: Arabic RTL PDF Reports

@poncho1234

Thanks for your guidance.. much appreciated. What worked for me is to comment the else statement at the end..I dont know what is it for. The rest I did not touch ..even the C in header2.inc stayed the same .. Changing it to L, R also works as expected.

if (!$this->rtl)
        {
            if ($align == 'right')
                $align = 'R';
            elseif ($align == 'left')
                $align = 'L';
            elseif ($align == 'center')
                $align = 'C';
            elseif ($align == 'justify')
                $align = 'J';
        }
        // else
        //    $align = 'R';

I dont know if this is a permanent  solution or it might affect other things.. I tested with different reports and looks fine to me.
Statement Report has a minor issue . I will look into it.

Re: Arabic RTL PDF Reports

Hi,

Tested reports and seem all OK for me at least.. here are some samples of rep107 and rep108

Post's attachments

rep107_revised.pdf 524.1 kb, 6 downloads since 2019-08-16 

You don't have the permssions to download the attachments of this post.

Re: Arabic RTL PDF Reports

And this is rep108

Post's attachments

rep108_revised.pdf 523.9 kb, 12 downloads since 2019-08-16 

You don't have the permssions to download the attachments of this post.

14 (edited by poncho1234 08/16/2019 02:49:26 pm)

Re: Arabic RTL PDF Reports

Glad you got it sorted, not sure if this is bug or as designed; it does seem a little incomplete that rtl just defaults all Textwrap alignments to right align though, I'll add it to mantis

The FrontAccounting Wiki(Manual, examples, tips, setup info, links to accounting sites, etc) https://frontaccounting.com/fawiki/

Re: Arabic RTL PDF Reports

Fixed by @joe in repo

Re: Arabic RTL PDF Reports

Tested the fix and its OK.