e代剑客——温柔一刀

生活就像海洋,只有意志坚强的人,才能到达彼岸

   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  76 随笔 :: 7 文章 :: 215 评论 :: 0 Trackbacks

jpivot是目前用得最多得OLAP展现工具,pentaho,spagoBI,openi等都是用他来做展现,

jpivot中pdf打印输出中文

1.升级com.tonbeller.jpivot.print.PrintServlet文件到JPivot1.6.0以上,如果不想升级就修改PrintServlet

在init方法中增加以下语句.   

public   void  init(ServletConfig config)  throws  ServletException {   
#     
super .init(config);   
#     
try  {   
#       
//  set base FOP FONT directory.  The font config  stuff will be looked for here   
#       Configuration.put( " fontBaseDir " , config.getServletContext().getRealPath( " /WEB-INF/jpivot/print/ " ));   
#       
//  get the physical path for the config file   
#       String fopConfigPath  =  config.getServletContext().getRealPath( " /WEB-INF/jpivot/print/userconfig.xml " );   
#       
//  load the user proerties, contining the CustomFont font.   
#        new  Options( new  File(fopConfigPath));   
#   
#     } 
catch  (FOPException e) {   
#       e.printStackTrace();   
#       logger.info(
" FOP user config file not loaded " );   
#     } 
catch  (Exception e) {   
#       e.printStackTrace();   
#       logger.info(
" FOP user config file not loaded " );   
#     }   
#   }  

2.在WEB-INF\jpivot\print目录下建立userconfig.xml文件。内容如下:(仅配置黑体)

< configuration >   
#   
< fonts >   
#   
< font  metrics-file ="simhei.xml"  kerning ="yes"  embed-file ="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>  
#   
# fonts>  
#   
# configuration>   

3. 下载Apache的FOP包,解开fop-0.20.5.jar,启用cmd,并到它的目录中,执行:

java org.apache.fop.fonts.apps.TTFReader -ttcname SimHei C:\WINDOWS\Fonts\simhei.ttf simhei.xml

然后就会生成需要的两个字体描述文件:simhei.xml

4. 将simhei.xml,以及simhei.ttf文件放到WEB-INF\jpivot\print目录下。

5. 修改WEB-INF\jpivot\table目录下的fo_mdxtable.xsl文件,把所有的font-family对应成SimHei

 jpivot excel导出中文

Excel中不支持UTF-8, Excel输出对应的xsl文件是:../web-inf/jpivot/table目录下的xls_mdxtable.xsl

只要这个文件的encoding换为GBK就可以了.

posted on 2007-07-11 20:28 温柔一刀 阅读(792) 评论(1)  编辑  收藏 所属分类: java相关

评论

# re: jpivot中输出pdf打印汉字、excel导出中文方法 2008-02-26 17:31 dfjinn
非常感谢,根据您的步骤,已成功打印PDF中文。非常感谢!  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航:
 
联系偶 zhupanjava@gmail.com 温柔一刀