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

Asian characters not showing in pdf files generated using cfdocument in CF 2021

New Here ,
Apr 28, 2022 Apr 28, 2022

Copy link to clipboard

Copied

After upgrading from Coldfusion 9 to Coldfusion 2021, I'm having issues with displaying Chinese/Japanese characters in the pdf files that are generated using cfdocument from html code. The characters display properly when output as html, but disappear when converted to pdf with cfdocument.

 

Any one else encounter this? Was there any changes to the pdf engine that Coldfusion uses?

 

Thanks!

Views

715

Translate

Translate

Report

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 ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

*Update*

Checking the generated pdf file, it seems to be using the same version iText 2.1.0 to generate the pdf files. 

Votes

Translate

Translate

Report

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
Community Expert ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

Well, that's a big jump from CF 9 to CF 2021! I'd recommend explicitly specifying a Unicode font, and using the CFPROCESSINGDIRECTIVE tag on the page with the CFDOCUMENT tag to explicitly specify UTF-8. Also, use the FONTEMBED attribute to ensure that, well, that Unicode font is embedded. Here's an example from Ben Nadel, who does a lot of CF stuff nowadays.

 

https://gist.github.com/bennadel/eda36df510b61efc59f2

 

Dave Watts, Eidolon LLC

 

Votes

Translate

Translate

Report

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 01, 2022 May 01, 2022

Copy link to clipboard

Copied

I'll give this a try, thanks!

Votes

Translate

Translate

Report

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
Community Expert ,
May 01, 2022 May 01, 2022

Copy link to clipboard

Copied

Let us know if this fixes the problem. Thanks!

 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

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 04, 2022 May 04, 2022

Copy link to clipboard

Copied

This does make the Asian characters become visible if the correct font is specified, but isn't really viable in my current use case, since the pdf being generated can contain a combination of English + other Asian characters. I would need to determine the language of the text and use the corresponding correct font for it (i.e. Korean uses different font from Chinese/Japanese to be displayed properly, etc.). In CF9 the font is automatically changed to the correct font if it's not possible to display with the specified font.

Votes

Translate

Translate

Report

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
Community Expert ,
May 05, 2022 May 05, 2022

Copy link to clipboard

Copied

I don't work with double-byte characters that often, but my understanding is that Unicode should represent them all: Chinese, Japanese, Korean, etc. So, the Arial Unicode font should do this as well. And when you use the UTF-8 processing directive instead of a region-specific one like ISO-8859-1 for Latin characters (English, most non-Cyrillic Western European languages) or whatever you use for Japanese or Korean regions, you should have the appropriate characters in the Unicode font. Here's a list of Hangul (Korean) characters in Arial Unicode MS:

 

https://www.fileformat.info/info/unicode/font/arial_unicode_ms/blockview.htm?block=hangul_jamo

 

Now, as I said, I have very little real-world experience dealing with these languages in Unicode, so keep that in mind. But the characters are there, and I'd try using a Unicode font and encoding to deliver them if I could.

 

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

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
Community Expert ,
May 08, 2022 May 08, 2022

Copy link to clipboard

Copied

To solve the problem, make sure that the HTML code has the appropriate fonts. The following example will show how.

 

The test files, test0 and test, each has HTML content. The content consists of text in Chinese and in Japanese characters. 

 

The content in test0 specifies no font. Whereas the content in test specifies the Microsoft Yahei font-family for the Chinese text and the Yu Gothic font-family for the Japanese text . For example:

 

<p style="font-family: 'Microsoft Yahei'">
<!--- Text with Chinese characters here --->
</p>

<p style="font-family: 'Yu Gothic'">
<!--- Text with Japanese characters here --->
</p>

 

 

Remove the TXT extension and place the files in wwwroot.

When you run the following code, you get a PDF with blank spaces in place of Chinese and Japanese characters:

 

<!--- test0.html specifies no font --->
<cfhttp method="get" url="http://127.0.0.1:8500/test0.html" />

<cfdocument format="pdf" fontembed="true">
	<cfoutput>#cfhttp.filecontent#</cfoutput>
</cfdocument>

 

 

When you run the following code, you get a PDF with Chinese and Japanese characters:

 

<!--- test.html specifies the respective fonts for Chinese and Japanese characters --->
<cfhttp method="get" url="http://127.0.0.1:8500/test.html" />

<cfdocument format="pdf" fontembed="true">
	<cfoutput>#cfhttp.filecontent#</cfoutput>
</cfdocument>

 

  

Votes

Translate

Translate

Report

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
Community Expert ,
May 20, 2022 May 20, 2022

Copy link to clipboard

Copied

@unknown_disorder , did that help?

Votes

Translate

Translate

Report

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 ,
Nov 08, 2022 Nov 08, 2022

Copy link to clipboard

Copied

sorry, this isn't feasible for my use case because in cases where name is user input, I can't be sure which language it will be in, so I am not able to identify which font to put into the html code.

Votes

Translate

Translate

Report

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
Community Beginner ,
May 26, 2022 May 26, 2022

Copy link to clipboard

Copied

Hello,

I also encountered the same problem.
Only occurs with ColdFusion2021, not a problem with CF2018 and CF2016, using same code and settings.
Tried in several environments with CF2021, but got same results that only displayed "abc" when in executing code below:

 

<cfdocument format="pdf" fontembed="true">
  <div style="font-family:IPAexMincho">abc あいうえお</div>
</cfdocument>

※Of course this "IPAexMincho" font is set up in admin page.

 

I don't think custom font is working.
I've tried Dave and BKBK ways, but unfortunately situation didn't change.

Is it related to the following problem or something?
https://tracker.adobe.com/#/view/CF-4211764

 

Or needed special settings other than CF2018?

 

Thank you.

Votes

Translate

Translate

Report

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
Community Expert ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

Thanks for sharing that, @KZNB . I hope Adobe will reopen the bug ticket. I have added a comment to the ticket, appealing to them to do so.

Votes

Translate

Translate

Report

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
Community Beginner ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

Hi @BKBK,

Thank you very much!

Hope they will respond in some way.

Votes

Translate

Translate

Report

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
Community Expert ,
May 27, 2022 May 27, 2022

Copy link to clipboard

Copied

 

Tried in several environments with CF2021, but got same results that only displayed "abc" when in executing code below:

 

<cfdocument format="pdf" fontembed="true">
  <div style="font-family:IPAexMincho">abc あいうえお</div>
</cfdocument>

※Of course this "IPAexMincho" font is set up in admin page.

 

 

Thank you.


By @KZNB

 

IPAexMincho is not one of the default fonts in the ColdFusion Administrator. So did you verify beforehand whether it is possible to integrate the font here? Did you install the font yourself? Did you follow the correct steps? 

 

In any case, I would strongly advise you to use standard fonts. For example, Microsoft Yahei font-family for Chinese text and Yu Gothic for Japanese text.

 

 

I don't think custom font is working.
I've tried Dave and BKBK ways, but unfortunately situation didn't change.

 

 

The standard fonts do work. At least, they do in the example I gave above. You perhaps made a mistake when you tried it. 

 

Your code does work with Yu Gothic. I tested the following, and it worked:

<cfdocument format="pdf" fontembed="true">
  <div style="font-family: 'Yu Gothic'">abc あいうえお</div>
</cfdocument>

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

Thank you for your advise.

 

I heavily use cfdocument and several fonts including IPAexMincho for Asian languages, and there is no problem at all on CF2018 and CF2016.


I would like to use built-in fonts, but must use "User Defined Fonts" for various languages(Traditional Chinese, Khmer etc.).

 

You can use Yu Gothic is a good news but our systems(CentOS7,8) don't have Yu Gothic as default, so that I installed as "User Defined Fonts" and tried out.

It didn't work however.


To set fonts automatically, located TTF file on /usr/share/fonts/default/TrueType and restart CF, it was displayed on "Current System Fonts", but situation was not changed.


Has anything changed font settings on to use "User Defined Fonts" on CF2021?

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 01, 2022 Jun 01, 2022

Copy link to clipboard

Copied

Hi @KZNB ,

Thank you for sharing that. Quite instructive.

My apologies for presuming that, like me, you're on Windows. 

 

I would suggest that you open a bug ticket

Votes

Translate

Translate

Report

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
Community Expert ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

Hi @KZNB ,

I have used your description to create this bug report: https://tracker.adobe.com/#/view/CF-4213775

Please review it and add any comments or feedback you may have.

In any case, vote for the ticket. 

Votes

Translate

Translate

Report

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
Community Beginner ,
Jun 03, 2022 Jun 03, 2022

Copy link to clipboard

Copied

Hello @BKBK ,

Sorry for late reply.

I should have described OS firstly.

Thank you so much for everythhing.

I deeply appreciate your help.

Votes

Translate

Translate

Report

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 ,
Mar 17, 2024 Mar 17, 2024

Copy link to clipboard

Copied

LATEST

都市開發前後的今昔對比,農田與都市

Votes

Translate

Translate

Report

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
Documentation