2.4. PDF
sudo apt-get install docbook-xml docbook-xsl xsltproc fop
安装字体
sudo mkdir /usr/share/fonts/microsoft
将 C:\Windows\Fonts 目录中的字体复制到 /usr/share/fonts/microsoft
$ java -cp /usr/share/java/fop.jar org.apache.fop.fonts.apps.TTFReader /usr/share/fonts/microsoft/simhei.ttf simhei.xml $ java -cp /usr/share/java/fop.jar org.apache.fop.fonts.apps.TTFReader -ttcname "SimSun" /usr/share/fonts/microsoft/simsun.ttc simsun.xml
sudo vim /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/param.xsl <xsl:param name="callout.unicode.font">simsun</xsl:param> <xsl:param name="symbol.font.family">simsun</xsl:param> <xsl:param name="callout.unicode.font">simsun</xsl:param>
$ vim fop.conf
<?xml version="1.0"?>
<fop version="1.0">
<base>.</base>
<renderers>
<renderer mime="application/pdf">
<filterList>
<value>flate</value>
</filterList>
<fonts>
<font metrics-url="simhei.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simhei.ttf">
<font-triplet name="simhei" style="normal" weight="normal"/>
<font-triplet name="simhei" style="normal" weight="bold"/>
<font-triplet name="simhei" style="italic" weight="normal"/>
<font-triplet name="simhei" style="italic" weight="bold"/>
</font>
<font metrics-url="simsun.xml" kerning="yes" embed-url="/usr/share/fonts/microsoft/simsun.ttc">
<font-triplet name="simsun" style="normal" weight="normal"/>
<font-triplet name="simsun" style="normal" weight="bold"/>
<font-triplet name="simsun" style="italic" weight="normal"/>
<font-triplet name="simsun" style="italic" weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
xsltproc -o helloworld.fo /usr/share/xml/docbook/stylesheet/docbook-xsl/fo/docbook.xsl helloworld.xml fop -c fop.conf helloworld.fo -pdf helloworld.pdf
原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。