将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);应该可以搞定!!

解决方案 »

  1.   

    落了一个标记!!!
    .....
    <configuration>
    <fonts>
       <font metrics-file="simkai.xml" kerning="yes" embed-file="simkai.ttf">
        <font-triplet name="simKai" style="normal" weight="normal"/>
     </font>
    .....
      

  2.   

    将字体文件拷贝到userconfig.xml同级目录下,也不好用。
    怎么办?什么原因呢?我的制作过程是这样的:
    我先是用WordXP作模板,然后存为htm文件。
    再使用wh2fo将htm文件转换为xml和xsl文件(在转换过程中出现了好多的DISCARDED INFO信息,不知是否正常?)。
    然后注册中文字体(出现上面的问题)。
    为了避免因出现错误而无法产生输出的情况,修改xsl文件中的一些内容
    最后使用fop命令将xml和xsl文件生成pdf文档(在此过程中也出现了好多的[ERROR]信息)。
    结果生成的pdf中中文显示为#,看到的表格和模板中的不一致,部分缺失。上述过程出现的问题,还请各位多加指正。
      

  3.   

    预注册字体没有问题你的config好像有问题,我现在也记不起来了,星期一告诉你,希望能互相学习
      

  4.   

    下面这段代码就是开体(simkai)在UserConfig中的设置,另外字体的xml文件在userconfig上级目录
    这种情况下只能处理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>
      

  5.   

    我在userconfig中的设置和上面写的一样。
    但无论把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是不是我在注册字体时就已经出现了错误(最开始我写的)?
      

  6.   

    [email protected]
    msn联系好吗?或者把你的userconfig.xml 和 simkai.xml 贴出来看看
    另外你的simkai.ttf的路径对吗?
      

  7.   

    java org.apache.fop.apps.Fop -c conf/userconfig.xml test.fo 11.pdf要自己加载userconfig.xml的
      

  8.   

    公司封掉了端口,上不了msn和qq,可以使用sinapager,我的号是7676071。
    我在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].
      

  9.   

    转换好的xml不作修改应该没有错误的,
    你userconfig.xml的写法应该也没有错误
    不知道你加载了没有?
    我感觉使用fop很麻烦,为什么不用其它转PDF的软件,你在研究FOP转PDF吗?另外你感觉wh2fo怎么样?
      

  10.   

    我也是刚刚接触几天。我们要做一个可以跨平台的系统(客户端也可能不是window平台),这就设计到打印的问题,最好的选择还是pdf了。至于wh2fo只是当作一个工具来用,转换过程中总是出现一些错误信息。可能是没用明白吧。对了不知道有没有将excel文件转成xml及xsl的软件。现在急需作出一个例子,但是问题多多,还得多多帮忙呀。
      

  11.   

    研究PDF的朋友看过来,尤其是用java语言的,比如itext,fop,xmlpdf,faceless 等http://expert.csdn.net/Expert/TopicView1.asp?id=1313903