Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

ColdFusion 8 drops Arabic characters when generating PDF doc

New Here ,
May 25, 2009 May 25, 2009

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

4.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 25, 2009 May 25, 2009

Hello All,

Attached you have the missing file print_test.cfm

Adrian

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 25, 2009 May 25, 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 25, 2009 May 25, 2009

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2009 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
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 26, 2009 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 26, 2009 May 26, 2009

this was done directly using Itext called from cf. it's your test phrase then arabic & farsi. how does this look?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2009 May 26, 2009

The Arabic part (first line) looks good. You said that you obtained the

PDF file by calling the Itext PDF Generator Engine from CF; I suppose

you did it through the cfdocument tag in a cfm document.

Since you previously reported that the file I posted also created a PDF

file with missing glyphs on your machine, please let me know how should

I modify my cfm file to make CF generate the PDF file properly with all

the glyphs in place.

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 26, 2009 May 26, 2009

"I suppose you did it through the cfdocument tag in a cfm document". nope i used

the iText library (the one that ships w/cf) directly in cf to see where the

problem actually was. i don't think this is something you want to do?

i reported this as a bug to adobe, you can help get something done by adding

your own bug report here:

https://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=12&6213=6

================ the cf file i used ================

<cfquery name="getU" datasource="lab"> SELECT uniText, uniLanguage FROM unicodeTest WHERE uniLanguage IN ('Arabic','Farsi') ORDER BY uniLanguage </cfquery> <cfscript>

// file

thisPDFFile="c:\Inetpub\wwwroot\iText\arabicLigatureTest.PDF";

// get objects

pdfFile = createObject("java", "java.io.FileOutputStream").init(thisPDFFile);

pageSize = createObject("java", "com.lowagie.text.PageSize").init();

bidiTable = createObject("java", "com.lowagie.text.pdf.PdfPTable").init(1);

//one column table

phrase = createObject("java", "com.lowagie.text.Phrase");

baseFont = createObject("java", "com.lowagie.text.pdf.BaseFont");

Font = createObject("java", "com.lowagie.text.Font");

Phrase=createObject("java", "com.lowagie.text.Phrase");

// landscape to fit this map image, the rotate() bit

//pdfDocument = createObject("java",

"com.lowagie.text.Document").init(PageSize.A4.rotate(), 0, 0, 0, 0);

// portrait

pdfDocument = createObject("java",

"com.lowagie.text.Document").init(PageSize.A4, 0, 0, 0, 0);

tableCell = createObject("java", "com.lowagie.text.pdf.PdfPCell");

PdfWriter = createObject("java", "com.lowagie.text.pdf.PdfWriter");

PdfWriter.getInstance(pdfDocument, pdfFile);

// add metadata BEFORE opening pdf doc

pdfDocument.addTitle("This is a quick and dirty arabic ligature test");

pdfDocument.addSubject("arabic ligature PDF test");

pdfDocument.addAuthor("PaulH");

pdfDocument.addCreator("arabicItext testbed");

pdfDocument.addKeywords("CFMX and iText are a great combination by golly!");

// lets setup unicode font

msUnicode=baseFont.createFont("c:
windows
fonts
ARIALUNI.ttf",

BaseFont.IDENTITY_H, BaseFont.EMBEDDED);

thisFont=Font.init(msUnicode,12);

// open doc to add stuff to then close, duh

pdfDocument.open();

bidiTable.setWidthPercentage(100);

bidiTable.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);

// leading, text, font

arabicPhrase=phrase.init(2,"نظام بصمة الوجه في دولة",thisFont);

c=tableCell.init(arabicPhrase);

c.setArabicOptions(8); //

c.setBorder(0);

c.setGrayFill(5.00);

bidiTable.addCell(c);

for (i=1; i LTE getU.recordCount;i=i+1) {

arabicPhrase=phrase.init(22,getU.uniText+,thisFont);

c=tableCell.init(arabicPhrase);

c.setArabicOptions(8);

c.setBorder(0);

c.setGrayFill(5.00);

bidiTable.addCell(c);

}

pdfDocument.add(bidiTable);

pdfDocument.close();

</cfscript

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 09, 2009 Oct 09, 2009

Is anyone aware if this is fixed in CF9?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 09, 2009 Oct 09, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2009 Oct 10, 2009
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources