Search code examples
phpms-worddocxopentbstinybutstrong

OpenTBS RTL issue


I'm using OpenTBS plugin for TinyButStrong to fill docx templates with data using PHP. When i'm trying to fill RTL text in the template, it is displayed in the right direction (from right to left) but the text itself seems messy.

for example, this string:

שלמה ארצי (זמר) + 2

Will be displayed as:

שלמה ארצי) זמר2 + (

Note that when i'm trying to copy this messy string to the notepad suddenly it displayed fine. and then when i copy it back to the Word it also fine.

any suggestions?


Solution

  • a bit of dirty solution, but after 6 hours of digging and testing this is the only solution i could make.

    PHP:

    function f_html2docx($FieldName, &$CurrVal, &$CurrPrm) {
        $CurrVal='</w:t></w:r><w:r><w:rPr><w:rFonts w:ascii="Arial" w:hAnsi="Arial" 
        w:cs="Arial"/><w:rtl/></w:rPr><w:t>'.$CurrVal.'</w:t></w:r><w:r><w:t>';
     }
    

    DOCX: (add the onformat and the strconv)

    [event.name;block=tbs:row;onformat=f_html2docx;strconv=no]