Thursday, August 12, 2010

How to render Chinese / Japanese correctly with cfdocument / cfreport?

In order to have the Chinese or Japanese characters rendered up correctly in PDF using and , you should first check what's your default locale at ColdFusion Administrator -> Setting Summary -> Java Default Locale.  One would have thought CFML will respect custom locale using setLocale(), but it doesn't.

If it is "en_US", edit /lib/cffont.properties.  Otherwise, create a /lib/cffont.properties.#locale#(e.g. /lib/cffont.properties.zh_TW )  using cffont.properties as reference.


Replace the font(s) after '=' with system's Chinese font (e.g. MingLiu) for Chinese or system's Japanese font (e.g. MS UI Gothic) for Japanese respectively, assuming ColdFusion is installed on Windows, and client has the respective font(s) installed.

Restart ColdFusion, and then the font should show up correctly...

p.s. In Report Builder, make sure you set Preference -> PDF Encoding to "Identity-H".

Now with the PDF open, Right-click -> Document Properties... , you should see the specified font  in the cffont properties file.

Hmm... now why can't PDF support UTF-8 correctly is beyond me...  How to display both Chinese and Japanese and Korean in the same PDF?  I don't know.

If you know which Chinese / Japanese / Korean fonts are installed by Adobe Reader language pack, please let me know here: http://stackoverflow.com/questions/3474221/which-fonts-are-installed-by-adobe-reader-asian-and-extended-language-font-packs

If you have a better method of getting cfreport / cfdocument render Chinese / Japanese / Korean, please share in Comments!

Thank you

update: if you don't need PDF, format="flashpaper" just works. Thanks Macromedia!