Skip to main content
Participant
May 25, 2009
Question

ColdFusion 8 drops Arabic characters when generating PDF doc

  • May 25, 2009
  • 4 replies
  • 4743 views

Hello All,

Please let me know what I'm doing wrong here! I have trouble with generating a PDF document from ColdFusion.

The cfm document contains mixed English and Arabic text and it seems that the ColdFusion's embedded PDF Generator drops Arabic characters when creating the PDF file.

I attached a bare bone cfm document (see print_test.cfm) that I used as an example to the stated problem.

The document:

  • displays fine in FireFox 3.0.10 (see attached print_test_screenshot.jpg) Used link:
  • is converted fine in PDF by the FireFox 3.0.10 using print command line (see attached print_test_firefox.pdf) Used command:
    • “C:\Program  Files\Mozilla Firefox\firefox.exe" -print "http://localhost:8500/Print_test.cfm?display=yes"  -printmode pdf -printfile "c:\pdf\print_test_firefox.pdf" -printdelay  150
  • is NOT converted to PDF properly by the ColdFusion using the embedded PDF generator (see attached print_test_cf.pdf) Used command


The print_test.cfm file, which I had to remove since this forum allows me to post only 3 attachments, has the following content:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<cfsavecontent variable="MyPage">

<head>
<title>PRINT TEST</title>
</head>

<body>
<table width="810" border="0">
  <tr>
    <td width="225" ><div align="center"><strong>ARABIC TEXT PRINT TEST</strong></div></td>
    <td width="225" ><div align="center"><strong><span dir="rtl">نظام بصمة الوجه في دولة</span></strong></div></td>
  </tr>
</table>
</body>
</html>
</cfsavecontent>

<cfif not(isdefined("url.DISPLAY"))>
        <cfdocument format="pdf" filename="c:\pdf\print_test_cf.pdf"  overwrite="yes">
        <cfoutput>#mypage#</cfoutput>
       
        </cfdocument>
    <cfelse>
   
    <cfoutput>#mypage#</cfoutput>
   
</cfif>

Thank you all for your help,

Adrian

    This topic has been closed for replies.

    4 replies

    Participating Frequently
    October 9, 2009

    Is anyone aware if this is fixed in CF9?

    Inspiring
    October 9, 2009

    Somewhat curiously, the attached code (print_test.cfm.txt (the second, 1.1 K version) works fine for me in both CF8 and CF9.  I cannot read Arabic, but certainly the resultant PDFs have what looks to be valid Arabic text (no weird icons, question marks or boxes) in them.

    I was a bit surprised that Paul didn't mention "you probably should have a <cfprocessingdirective> tag in your CFM file if it's going to include non-ASCII characters".  That's my usual source of grief with this sort of thing (my exposure to this sort of problem was with Cyrillic, not Arabic though).  Perhaps CF8 & CF9 have got better at detecting UTF-8 files without the need for hard-coded prompting.

    --

    Adam

    Participating Frequently
    October 10, 2009

    Adam,

    Thanks for pointing the <cfprocessingdirective> tag out. I am just working on my first Arabic web site and that was the first gocha I found.

    I havn't actually tried generating PDFs yet but its on the list and I am hoping it doesn't give me any grief.

    Kevin

    Inspiring
    May 26, 2009

    is it the letter "feh" (U+0641)?

    adrain68Author
    Participant
    May 26, 2009

    Paul,

    1. Here there are the details you asked me for:

    Version Information
    Server Details
    Server ProductColdFusion
    Version8,0,1,195765
    EditionEnterprise (Trial)
    Serial Number
    Operating SystemWindows XP
    OS Version5.1
    Adobe Driver Version3.6 (Build 0027)

    2. I updated cfm file attached containing the Unicode characters. The missing chars are U+0641 and U+064A.

    3. The two unicodes do form a ligature.

    4. I suppose that the system default font has that character since it is displayed fine in the both the browser and Notepad. Please correct me if I'm wrong.

    5. Also the character displays fine in VB6 with Chilkat CharSet using any of the default Traditional Arabic, Arabic Simplified, Simplified Arabic Fixed, or Andalus fonts.

    6. These four fonts are also present in the ColdFusion's Font Management: Current System Fonts. I tried explicitly to invoke them in the cfm document but nothing changed.


    Please let me know if the attached print_test.cfm generate properly (no missing glyphs) the output file C:\PDF\print_test_cf.pdf on your machine.

    Thank you,
    Adrian
    Inspiring
    May 26, 2009

    ...swell quoted email text still doesn't work.

    drain68 wrote:
    > 2. I updated cfm file attached containing the Unicode characters. The missing
    > chars are U+0641 and U+064A.

    ok.

    > 3. The two unicodes do form a ligature.

    ok. i thought it would be these.

    > 4. I suppose that the system default font has that character since it is
    > displayed fine in the both the browser and Notepad. Please correct me if I'm
    > wrong.

    the PDF is generated server side, so the fonts have to be on the server (though
    i guess in your case client/server are the same) but different apps might use
    different default fonts.

    > 5. Also the character displays fine in VB6 with Chilkat CharSet using any of
    > the default Traditional Arabic, Arabic Simplified, Simplified Arabic Fixed,
    > or Andalus fonts.

    and that does PDF generation?

    > 6. These four fonts are also present in the ColdFusion's Font Management:
    > Current System Fonts. I tried explicitly to invoke them in the cfm document
    > but nothing changed.

    yes i tried with ms arial unicode (i would recommend that font to you if you do
    a lot of i18n work) that char wasn't present in the output.

    > Please let me know if the attached print_test.cfm generate properly (no
    > missing glyphs) the output file C:\PDF\print_test_cf.pdf on your machine.

    nope, i got the same thing w/your code.

    let me run this "directly" thru iText before we call "bug" in cf.

    Message was edited by: PaulH

    Inspiring
    May 26, 2009

    probably a good idea to tell us exactly what char is missing (at least it's

    unicode codepoint value). is it a ligature? does the system default font have

    that char? have you tried other fonts? what version of cf? hotfixes, etc. applied?

    adrain68Author
    Participant
    May 25, 2009

    Hello All,

    Attached you have the missing file print_test.cfm

    Adrian