Hi,
I am facing the routine problem with generating multilingual pdf using Apache
FOP
Requirement: We should be able to generate PDF in Asian/multiple
languages(Japanese, Chinese etcc.,) using Apache FOP
Current Set up: Current system is using Apache FOP to generate PDF in english
at the runtime. The .fo file (containing information about the blocks and data
to be written to PDF) and userconfig file(containing information about the
fonts) content is constructed at the run time based on the data available in
the Database.
Solution Tried so far: After analyzing i found that we need to embedd fonts
related to japanese or chinese etcc specifically in to the PDF, following are
the steps I followed to do the same.
1) Downloaded latest fop.jar (fop-0.95-bin.zip ) from
http://mirrors.ecvps.com/apache/xmlgraphics/fop/binaries/
2) Created font metric files for ARIALUNI and MS Gothic fonts as specified at
http://www.zvon.org/HowTo/Output/cid-fonts.pdf
3) Ensured that the userconfig.xml has the following font entries
<font metrics-file="ARIALUNI.xml" kerning="yes" embed-file="ARIALUNI.TTF">
<font-triplet name="Arial Unicode MS" style="normal" weight="normal" />
</font>
<font metrics-file="msgothic.xml" kerning="yes" embed-file="msgothic.ttc">
<font-triplet name="MS-Gothic" style="normal" weight="normal"/>
</font>
4) Ensured that .fo file generated uses the above specified font for the
certain blocks which contains the Japanese text.
Even after performing the above steps, I see the content being displayed as
つのコメントをテスト
or as ?????????????????????
instead of displaying it in Japanese text.
NOTE:
1) The japanese text that needs to be displayed is picked from the database,
and in the database we see the information as
つのコメントをテスト
when we try to view it using TOAD. I am fetching the same information and
displaying it in one of the text field in the page where in it is displaying
appropriately as Japanese text (This is because i am setting the
charset/pageEncoding to UTF-8).
2) There was no "MS Gothic.ttf" in C:\WINDOWS\fonts dir so i have used "MS
Gothic.ttc" to generate the font metric file for the same initially and later i
downloaded MSGothic.ttf from internet and tries the same , and in the
userconfig.xml I tried to specify both (one at a time) for embed-file property
i tried the following entry once
<font metrics-file="MSGothic.xml" kerning="yes" embed-file="MSGothic.ttf">
<font-triplet name="MS Gothic" style="normal" weight="normal"/>
</font>
and then
<font metrics-file="MSGothic.xml" kerning="yes" embed-file="MSGothic.ttc">
<font-triplet name="MS Gothic" style="normal" weight="normal"/>
</font>
Questions I have:
1) The .fo file created at runtime has the Japanese content as
つのコメントをテスト
isntead of Japanese characters. Is this fine? Enclosed is the sample
"Template_user10_.fo" file that is getting generated.
2) Enclosed are userconfig.xml and font metric files for MS Gothic and
ARIALUNI. Check if these are fine.
3) Guide/Suggest what all we have to in order to properly write Asian
languages/Japanese/Chinese to PDF's using Apache FOP. The version of FOP used
in our application is 0.20.5, but i have used 0.95 version to generate the
metrics file, will it create a problem? Can you please guide the appropriate
versions to be used during the whole process.
Regards,
Srinivas