Apache FOP 学习笔记
Apache™ FOP (Formatting Objects Processor) is a print formatter driven by XSL formatting objects (XSL-FO) and an output independent formatter. It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PS, PCL, AFP, XML (area tree representation), Print, AWT and PNG, and to a lesser extent, RTF and TXT. The primary output target is PDF.
问题处理
中文显示
- 自动检测系统字体库
fop.xconf
默认配置为自动检测。
注意使用正确的字体家族名称。(可使用 Windows 自带字体查看器查询)1
2
3
4
5<fo:block color="green" font-family="华文行楷">
Hello, <xsl:value-of select="name"/>!
<fo:external-graphic src="asf-logo.png"/>
中文测试
</fo:block> - 添加自定义字体库
在配置文件中注册字体fop.xconf
可以任意定义字体名称font-triplet name="xxx"
,使用时与其保持一致即可。font-family="xxx"
1
2
3<font kerning="yes" embed-url="HanBiaoLiXuKeShuFa.ttf">
<font-triplet name="LiXuKeShuFa" style="normal" weight="normal"/>
</font>