Generate PDF from Document Template,can not display chinese.

0
Hi, I am using document template to generate a pdf file.    then content of it is Chinese language. But the pdf document only can display english chars,  all chinese char display with ‘#’. I have do the app translation on document template.  and set the language to ‘zh_CN’ .    but still not work. What more should i to do? Regards Haiji  
asked
4 answers
3

You need to add a chinese font to your resource map. This blog post tell's you how to do that: https://www.notion.so/Generating-PDF-A-compliant-documents-01ff7b8462e0404eac21b178784cae7d

Regards,

Ronald

 

answered
2

After spending lots of time R&D to make PDF display Chinese font, instead of ‘###’.

This is the result in PDF:

 

Additional Note:
Changing the Default Log Level from ‘Info’ → ‘Trace’ (allow me to understand regarding how Mendix read the font-triplet name (eg. lower-case “arial unicode ms”, instead of “Arial Unicode MS”)

 

fyi, you will need to copy the "original fop.xconf”, and paste into your resource.
 →  “yourproject-main\resource\”

 

File path: ...yourproject-main\resources\fop.xconf

<font kerning="yes" embed-url="arial-unicode-ms.ttf" embedding-mode="full">
	<font-triplet name="arial unicode ms" style="normal" weight="normal"/>
</font>

 

Overview on how I apply the “arial unicode ms” to diplay Chinese word

you need to download the “Arial Unicode MS” from the internet, and then rename the file to “arial-unicode-ms.ttf” (easier to use this name)

you may read https://forum.mendix.com/link/questions/100161 to get more info.

answered
1

HI Hiji Du,

The Link given by Ronald is absolutely right.
Might be i can give you few more suggestions. Instead of creating a new fop.Xocnf file in your resource folder we can just copy the fop.xconf file from the Directory where mendix modelor is installed.  Ex:  C:\Program Files\Mendix\8.18.3.16826\runtime\lib, in this directry copy the Fop.xcponf file and paste it in your Ressource folder. 

Then download the ttf files for Chinese language and place it in the Resources folder. Now open the fop.xocnf file and you should add your code in between the <fonts> </fonts> tags.

Ex:

 <font kerning="yes" embed-url="arialbd.ttf" embedding-mode="full">

<font-triplet name="Arial" style="normal" weight="bold"/>

<font-triplet name="ArialMT" style="normal" weight="bold"/>

</font>

 

The triplet name should be same as mentioned in the TTF file. you can open the ttf file and find the font name. 

Note : You should downlaod the TTf for all triplets mentioned int he Xconf file.

After this set up is done, Should go to your Template document and you should add you custom css to your dynamix text in document .

 css: 
font-family: ‘your font name defined in the fop.conf file’ 
 

Hope it is helpful :)

answered
0

This is the pdf content.    Try to generate  html and word file, they display correct.

answered