# autounmask dev-java/fop-0.94-r1
据说fop对中文的断行支持得比0.93好。另外"zh_cn"也可以正确处理了。# emerge fop -av
#java -cp
/usr/share/fop/lib/fop.jar:/usr/share/avalon-framework-4.2/lib/avalon-framework.jar:/usr/share/commons-logging/lib/commons-logging.jar:/usr/share/commons-io-1/lib/commons-io.jarorg.apache.fop.fonts.apps.TTFReader/usr/share/fonts/fireflysung/fireflysung.ttf fireflysung.xml
TTF Reader for FOP 0.94
Parsing font...
Reading /usr/share/fonts/fireflysung/fireflysung.ttf...
Font Family: AR PL New Sung
Creating xml font file...
Creating CID encoded metrics...
Writing xml font file fireflysung.xml...
This font contains no embedding license restrictions.
XML font metrics file successfully created.
# java -cp /usr/share/fop/lib/fop.jar:/usr/share/avalon-framework
-4.2/lib/avalon-framework.jar:/usr/share/commons-logging/lib/commons-logging.jar:/usr/share/commons-io-1/lib/commons-io.jarorg.apache.fop.fonts.apps.TTFReader -ttcname "SimSun"/usr/share/fonts/winfonts/simsun.ttf simsun.xml
TTF Reader for Apache FOP 0.94
Parsing font...
Reading /usr/share/fonts/winfonts/simsun.ttf...
This is a TrueType collection file with 2 fonts
Containing the following fonts:
SimSun <-- selected
NSimSun
Font Family: SimSun
Creating xml font file...
Creating CID encoded metrics...
Writing xml font file simsun.xml...
This font contains no embedding license restrictions.
XML font metrics file successfully created.
# mkdir /etc/fop
# mv *.xml /etc/fop
# cp /usr/share/doc/fop-0.94-r1/examples/conf/fop.xconf /etc/fop
# cd /etc/fop
建立zhfop.conf的内容如下:
.
flate
embed-url="/usr/share/fonts/winfonts/simsun.ttf">
# cat /usr/share/sgml/docbook/xsl-stylesheets/fo/docbookzhcn.xsl
xmlns:fo=""
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
exclude-result-prefixes="doc"
version="1.0">
SimSun
12
SimSun
SimSun
2cm
2cm
false
- 用xsltproc来生成HTML或者XSL-FO文件
譬如,下面是根据Docbook文档生成HTML的例子:
$ xsltproc --output myfile.html /usr/share/sgml/docbook/xsl-stylesheets/html/docbook.xsl myfile.xml
或者根据docbook文档生成XSL-FO文档的例子:
$ xsltproc --output myfile.fo /usr/share/sgml/docbook/xsl-stylesheets/fo/docbook.xsl myfile.xml
$ fop -c /etc/fop/zhfop.conf -xsl /usr/share/sgml/docbook/xsl-stylesheets/fo/docbookzhcn.xsl -xml myfile.xml -pdf myfile.pdf