将simkai.ttf拷贝到userconfig.xml同级目录下,在userconfig.xml中加入
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<configuration>
<font metrics-file="simkai.xml" kerning="yes" embed-file="simkai.ttf">
<font-triplet name="simKai" style="normal" weight="normal"/>
</font>
</fonts>
</configuration>
然后,在代码中加入
File files=new File("usercfg.xml");
if(files.exists())System.out.println("Exits!!");
Options options = new Options();
options.loadUserconfiguration(files);应该可以搞定!!
<!--<!DOCTYPE configuration SYSTEM "config.dtd">-->
<configuration>
<font metrics-file="simkai.xml" kerning="yes" embed-file="simkai.ttf">
<font-triplet name="simKai" style="normal" weight="normal"/>
</font>
</fonts>
</configuration>
然后,在代码中加入
File files=new File("usercfg.xml");
if(files.exists())System.out.println("Exits!!");
Options options = new Options();
options.loadUserconfiguration(files);应该可以搞定!!
.....
<configuration>
<fonts>
<font metrics-file="simkai.xml" kerning="yes" embed-file="simkai.ttf">
<font-triplet name="simKai" style="normal" weight="normal"/>
</font>
.....
怎么办?什么原因呢?我的制作过程是这样的:
我先是用WordXP作模板,然后存为htm文件。
再使用wh2fo将htm文件转换为xml和xsl文件(在转换过程中出现了好多的DISCARDED INFO信息,不知是否正常?)。
然后注册中文字体(出现上面的问题)。
为了避免因出现错误而无法产生输出的情况,修改xsl文件中的一些内容
最后使用fop命令将xml和xsl文件生成pdf文档(在此过程中也出现了好多的[ERROR]信息)。
结果生成的pdf中中文显示为#,看到的表格和模板中的不一致,部分缺失。上述过程出现的问题,还请各位多加指正。
这种情况下只能处理normal style,normal weight,如果要处理什么斜体,bold字体之类的就要自己研究下了,我就不多说了,字体文件名要用完整路径 <font metrics-file="simkai.xml" kerning="yes" embed-file="C:\WINNT\Fonts\simkai.ttf">
<font-triplet name="KaiTi_GB2312" style="normal" weight="normal"/>
</font>
但无论把xml文件放在与userconfig同一文件夹下还是userconfig的上一级文件夹下都不好使。使用fop始终出现:
…………
[INFO] [1]
[ERROR] unknown font KaiTi_GB2312,normal,normal so defaulted font to any
[ERROR] unknown font KaiTi_GB2312,normal,normal so defaulted font to any
…………
[INFO] Parsing of document complete, stopping renderer是不是我在注册字体时就已经出现了错误(最开始我写的)?
msn联系好吗?或者把你的userconfig.xml 和 simkai.xml 贴出来看看
另外你的simkai.ttf的路径对吗?
我在userconfig.xml中添加的语句(我的系统在d盘):
<font metrics-file="simhei.xml" kerning="yes" embed-file="D:\WINNT\Fonts\simhei.ttf">
<font-triplet name="SimHei" style="normal" weight="normal"/>
</font>
<font metrics-file="simkai.xml" kerning="yes" embed-file="D:\WINNT\Fonts\SIMKAI.TTF">
<font-triplet name="KaiTi_GB2312" style="normal" weight="normal"/>
</font>
simkai.xml内容太多。
发邮件如何?我的mail:[email protected].
你userconfig.xml的写法应该也没有错误
不知道你加载了没有?
我感觉使用fop很麻烦,为什么不用其它转PDF的软件,你在研究FOP转PDF吗?另外你感觉wh2fo怎么样?