首先,技术为apache 的FOP,初级的问题我就不写了,下面记录一下遇到的问题的解决方案:
?
这个问题网上的解决方案非常之多,也不详细描述了,每个使用FOP的都会遇见,还是记录一下。
在fop.xconf文件中,修改pdf相关的render,添加中文字体配置
?
<renderer mime="application/pdf">
<filterList>
<!-- provides compression using zlib flate (default is on) -->
<value>flate</value>
</filterList>
<fonts>
<font metrics-url="[%FOP_ROOT%]/simsun.xml" kerning="yes" embed-url="[%FOP_ROOT%]/fonts/simsun.ttc">
<font-triplet name="SimSun" style="normal" weight="normal"/>
<font-triplet name="宋体" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>
?当然你还使用其他的方式来添加字体配置,见http://xmlgraphics.apache.org/fop/0.95/configuration.html
?其中的.xml文件是根据fop的字体读取类生成的,例如: