JasperReports: fonts issues [UniJIS-UCS2-H (Japanese)]- converting old reports to new version

孤街浪徒 提交于 2019-12-11 20:47:44

问题


I am sure this question was asked so many times before, just need some clarification, i have bunch of reports made using older version of the iReport 2.x and JasperReports 3.1.0, when I tried to recompile using the latest version of both iReport and JR report, i keep getting error.

Error exporting print... Could not load the following font :  
pdfFontName   : HeiseiKakuGo-W5 
pdfEncoding   : UniJIS-UCS2-H 
isPdfEmbedded : true

Many of the older reports uses these fonts: HeiseiKakuGo-W5, HeiseiMin-W3

I am pretty confused regarding this. Basically these reports are created 4 years back by my japanese co-worker and I haven't touched reports for over 3 years now. Now i am running blind.

The same report I am trying to run..

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report1ss" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="206064b5-8017-408d-8a01-fd738237b865">
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <textField>
                <reportElement uuid="a17f1430-f415-4eba-9769-b02ca05731a8" x="156" y="17" width="112" height="62"/>
                <textElement>
                    <font fontName="MS Mincho" pdfFontName="HeiseiMin-W3" pdfEncoding="UniJIS-UCS2-H" isPdfEmbedded="true"/>
                </textElement>
                <textFieldExpression><![CDATA["入 学 許 可 証"]]></textFieldExpression>
            </textField>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

I get the following error

Exporting PDF (using iText) to file... C:\Users\prabhu\Desktop\mod_recipt_test1\report1ss.pdf!
Error exporting print... Could not load the following font :  
pdfFontName   : HeiseiKakuGo-W5 
pdfEncoding   : UniJIS-UCS2-H 
isPdfEmbedded : true

I just want to know do I need to buy these fonts from some vendor to use via the font extension jars or I am doing something wrong. Last time when I used iReport I just had to set the pdffontname and pdfencoding and everything went fine, Sighs i am so so outdated... if someone can give me a quick pointer or hint it would be great help for me...

BTW: I have also asked my company to try and find out where they can buy the fonts.


回答1:


OK after many trail and errors, i managed to find out proper way to do the task.

  1. Do we need the fonts to be present in the system/class path ? yes and seems like only ttf works properly. Basically the font need to be available in the system so JVM can access it. [packaging it into jar file is easier way .]
  2. Use all updated jar files, mix matching versions causing issues. you need itext, itext-asian, jasper and jasper-fonts. [maven repository would be a good place to look for the jar files. ]
  3. And for the font name. after searching a lot just decided to use the Sazanami Mincho font, which is freely available in centos package. [ this font is installed when you install the Japanese language support]

this is the parameter that worked for me

fontname      : Sazanami Mincho
pdfFontName   : HeiseiKakuGo-W5 
pdfEncoding   : UniJIS-UCS2-H 
isPdfEmbedded : true

@Alex K thanks for tidying up my question.



来源:https://stackoverflow.com/questions/17561929/jasperreports-fonts-issues-unijis-ucs2-h-japanese-converting-old-reports-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!