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 溫柔一刀 閱讀(840) 評論(1)  編輯  收藏 所屬分類: java相關

          評論

          # re: jpivot中輸出pdf打印漢字、excel導出中文方法 2008-02-26 17:31 dfjinn
          非常感謝,根據您的步驟,已成功打印PDF中文。非常感謝!  回復  更多評論
            

          聯系偶 zhupanjava@gmail.com 溫柔一刀
          主站蜘蛛池模板: 镇雄县| 延津县| 庆城县| 浪卡子县| 延寿县| 奉新县| 济阳县| 凭祥市| 娄底市| 新乡县| 疏附县| 晋宁县| 许昌市| 孟连| 舞阳县| 三都| 全州县| 蛟河市| 马公市| 营口市| 广元市| 河曲县| 遂昌县| 江北区| 西乡县| 故城县| 合肥市| 古田县| 公主岭市| 南丹县| 东莞市| 奎屯市| 西城区| 河曲县| 陕西省| 华坪县| 靖安县| 秀山| 昭平县| 九台市| 尖扎县|