ofbiz中fop国际化

来源:互联网 发布:怎样测试网络丢包 编辑:程序博客网 时间:2024/06/04 18:29

1、下载fop

2、 建立font metrics文件,对ttcttf有不同的方法

fop的根目录下执行

java -cp build/fop.jar;lib/avalon-framework.jar;lib/xml-apis.jar;lib/xercesImpl.jar;lib/xalan.jar org.apache.fop.fonts.apps.TTFReader C:/WINNT/Fonts/simkai.ttf simkai.xml
java -cp build/fop.jar;lib/avalon-framework.jar;lib/xml-apis.jar;lib/xercesImpl.jar;lib/xalan.jar org.apache.fop.fonts.apps.TTFReader -ttcname "SimSun" C:/WINNT/Fonts/simsun.ttc simsun.xml

-ttcname后面指定需要从ttc文件中提取的字体名称,两个命令中都要注意大小写。

         3、修改fop的根目录中的/confi/userconfig.xml,在<fonts></fonts>中间增加

<font metrics-file="framework/common/config/simhei.xml" kerning="yes" embed-file=" framework/common/config/simhei.ttf">

         <font-triplet name="mysimhei" style="normal" weight="normal"/>

</font>

         Metrics-fileembed-file的值是文件相对于ofbiz的路径。

         4、将生成的.xml文件、字体文件和userconfig.xml放在ofbiz中你要放的目录下。.xm所放的目录必须与Metrics-file中所写的路径一致。字体文件所放的目录必须与embed-file中所写的路径一致。

         5、修改你的.fo.ftl文件。

             ·将需要改变字体的<fo:block>添加font-family属性(如<fo:block font-family="JaFont">オーダ</fo:block>)。Font-family的值与usercongfig.xmlfont-triplet中的name的值一致。

    6、写.bsh文件

        Path.bsh:

       

        import java.io.File;

import org.apache.fop.apps.FOPException;

import org.apache.fop.apps.Options;

File userConfig= new File("framework/common/config/userconfig.xml");

if(userConfig.exists()){

    try {

        Options options = new Options(userConfig);

    } catch (FOPException e) {}

}

.bsh文件加到

    <screen name="testPDF">

        <section>

            <actions>

                <script location="component://test/webapp/test/WEB-INF/actions/test/path.bsh"/>

            </actions>

            <widgets>

                <platform-specific>

                    <html><html-template location="component://test/webapp/accounting/test/test.fo.ftl"/></html>

                </platform-specific>               

            </widgets>

        </section>

    </screen>

中。

  呵呵这样就可以了
原创粉丝点击