Skip to main content
Inspiring
August 30, 2017
Question

Issue in the order of display of Arabic texts in PDF file generated using ColdFusion

  • August 30, 2017
  • 1 reply
  • 1325 views

I have a query result set as given below.

I want to display details from this query in a pattern of name1 amount1  unit1,name2 amount2 unit2,name3 amount3 unit3,name4 amount4 unit 4 and that too in RTL (Right To Left) direction since data from the query is Arabic.

For example : please see the screen shot of pdf file.

Issue:Order of Arabic text is not correct as expected as given in the above screenshot. Below is the code snippet I used to generate pdf but order of display is wrong.

    <cfset local.qBuckets = QueryNew("amount,name,unit","varchar,varchar,varchar") />

    <cfset Queryaddrow(local.qBuckets,4)>

    <cfset x=1>

    <cfset Querysetcell(local.qBuckets,'amount','غير محدودة',x)>

    <cfset Querysetcell(local.qBuckets,'name','لبيانات المحلية والعالمية',x)>

    <cfset Querysetcell(local.qBuckets,'unit','جيجابايت',x)>

    <cfset y=2>

    <cfset Querysetcell(local.qBuckets,'amount','600',y)>

    <cfset Querysetcell(local.qBuckets,'name','الدولية',y)>

    <cfset Querysetcell(local.qBuckets,'unit','دقيقة',y)>

    <cfset z=3>

    <cfset Querysetcell(local.qBuckets,'amount','300',z)>

    <cfset Querysetcell(local.qBuckets,'name','التجوال الوارد',z)>

    <cfset Querysetcell(local.qBuckets,'unit','دقيقة',z)>

    <cfset p=4>

    <cfset Querysetcell(local.qBuckets,'amount','غير محدودة',p)>

    <cfset Querysetcell(local.qBuckets,'name','المكالمات المحلية / الرسائل القصيرة',p)>

    <cfset Querysetcell(local.qBuckets,'unit','جيجابايت',p)>

    <cfoutput>

    <cfdocument filename="c:\arr-bill.pdf" format="pdf" overwrite="true">

    <table border="0" cellspacing="0" cellpadding="5" align="center" style="width:190mm;direction: rtl;">

    <tr>

    <td style="border-bottom:1pt solid ##000000;">

    <span style="font-size:10pt; font-weight:bold;">Red 750</span>

    <BR />

    <span style="font-size:9pt;">

    <cfset attributes.bucketSep = "">

    <cfloop query="local.qBuckets">

    #attributes.bucketSep# <span style="font-weight: bold;color:black;">#name#</span>

    #amount# #unit#

    <cfset attributes.bucketSep = ",">

    </cfloop>

    </span>

    </td>

    </tr>

    </table>

    </cfdocument>

    </cfoutput>

Notes: Order of Arabic text is correct in HTML output (in browser). Also , the order is correct in pdf file but only when I remove the span used around the name.

PDF generating code where order is correct

    <cfdocument filename="c:\arr-bill.pdf" format="pdf" overwrite="true">

    <table border="0" cellspacing="0" cellpadding="5" align="center" style="width:190mm;direction: rtl;">

    <tr>

    <td style="border-bottom:1pt solid ##000000;">

    <span style="font-size:10pt; font-weight:bold;">Red 750</span>

    <BR />

    <span style="font-size:9pt;">

    <cfset attributes.bucketSep = "">

    <cfloop query="local.qBuckets">

    #attributes.bucketSep# #name#

    #amount# #unit#

    <cfset attributes.bucketSep = ",">

    </cfloop>

    </span>

    </td>

    </tr>

    </table>

    </cfdocument>

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
August 31, 2017

What about going along with the default left-to-right, and doing something as simple as this:

<cfdocument filename="c:\arr-bill.pdf" format="pdf" overwrite="true">

<span style="font-size:10pt; font-weight:bold;">Red 750</span>

<table border="0" cellspacing="0" cellpadding="5" align="center" style="width:190mm">

<cfoutput query="local.qBuckets">

   <tr>

   <span style="font-size:9pt;">

      <td>#unit#</td>

      <td>#amount#</td>

      <td><span style="font-weight: bold;color:black;">#name#</span></td>

   </span>

   </tr>

</cfoutput>

</table>

</cfdocument>

Inspiring
September 5, 2017

Thank you for your response. But this will show data in tabular format and my client want it to be shown in comma separated values and that too in Right To Left direction(as I given in the above code under the heading "PDF generating code where order is correct" ) . But here I am facing an issue to highlight the "name" field (used "span" around the name field but thats not working). Would be much helpful if you could help me fix this issue instead of an alternate solution.

BKBK
Community Expert
Community Expert
September 5, 2017

I'm sorry my suggestions are limited. I am unable to read the output, so cannot tell right from left.