Apache FOP Chinese Character Display Issues
When using Apache FOP to print PDF documents, Chinese characters may appear as "####" despite having the necessary language files installed. This issue is caused by a lack of font support in the default configuration.
To resolve this issue, three steps are required:
Step 1: Specify Font Family in FO File
Indicate the desired font using the font-family property. For example:
博洛尼亚大学中国学生的毕业论文
Step 2: Configure Font Mapping in FOP's Configuration File
In fop.xconf, add font mappings to the font file:
/path/to/SimSun.ttf
Or you can add a directory to map all fonts in that directory:
/path/to/Fonts
Step 3: Reference Configuration File
Use the -c option when calling FOP from the command line:
$ fop -c /path/to/fop.xconf input.fo input.pdf
From Java code, use setUserConfig().
Once all three steps are complete, Chinese characters should be displayed correctly in the PDF document.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3