Jasper Report字体错误

时间:2013-11-14 13:11:15

标签: jasper-reports

在Windows中如何解决此问题错误部分为net.sf.jasperreports.engine.util.JRFontNotFoundException: Font

我正在尝试使用 JasperReports 生成pdf文件。

Exception in thread "main" java.lang.ExceptionInInitializerError
at net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:121)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:88)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:103)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:61)
at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:153)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:55)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:446)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:849)
at com.p41.jasper.ReportGenerator.generateReport(ReportGenerator.java:46)
at com.p41.jasper.ReportGenerator.main(ReportGenerator.java:67)
Caused by: net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '
    net/sf/jasperreports/fonts/pictonic/pictonic.ttf
    net/sf/jasperreports/fonts/pictonic/pictonic.svg
    net/sf/jasperreports/fonts/pictonic/pictonic.eot
    net/sf/jasperreports/fonts/pictonic/pictonic.woff
' is not available to the JVM. See the Javadoc for more details.
at net.sf.jasperreports.engine.util.JRFontUtil.checkAwtFont(JRFontUtil.java:358)
at net.sf.jasperreports.engine.fonts.SimpleFontFace.getInstance(SimpleFontFace.java:72)
at net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:99)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:261)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:232)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:193)
at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:162)
at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:56)
at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83)
... 10 more

这是我的 jrxml 文件:

<?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="itemreport" pageWidth="1600" pageHeight="595" orientation="Landscape" columnWidth="1560" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
    <queryString>
        <![CDATA[select Id,Empno,Depart,Empname,Desig,Locat  from shom]]>
    </queryString>

    <field name="Id" class="java.lang.Integer"/>
    <field name="Empno" class="java.lang.String"/>
    <field name="Depart" class="java.lang.String"/>
    <field name="Empname" class="java.lang.String"/>
    <field name="Desig" class="java.lang.String"/>
    <field name="Locat" class="java.lang.String"/>

    <group name="id">
        <groupExpression><![CDATA[$F{Id}]]></groupExpression>
    </group>

    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement x="296" y="22" width="348" height="42"/>
                <textElement>
                    <font size="30" isBold="true"/>
                </textElement>
                <text><![CDATA[ItemMaster Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Id]]></text>
            </staticText>
            <staticText>
                <reportElement x="100" y="0" width="153" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Empno]]></text>
            </staticText>
            <staticText>
                <reportElement x="253" y="0" width="206" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Depart]]></text>
            </staticText>
            <staticText>
                <reportElement x="459" y="0" width="141" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Empname]]></text>
            </staticText>
            <staticText>
                <reportElement x="600" y="0" width="189" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Desig]]></text>
            </staticText>
            <staticText>
                <reportElement x="1145" y="0" width="274" height="20"/>
                <textElement>
                    <font size="15" isBold="true"/>
                </textElement>
                <text><![CDATA[Locat]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="43" splitType="Stretch">
            <textField>
                <reportElement x="0" y="0" width="100" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.Integer"><![CDATA[$F{Id}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="100" y="0" width="153" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{Empno}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="253" y="0" width="206" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{Depart}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="459" y="0" width="141" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{Empname}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="600" y="0" width="189" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{Desig}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="1145" y="0" width="274" height="20"/>
                <textElement>
                    <font size="15"/>
                </textElement>
                <textFieldExpression class="java.lang.String"><![CDATA[$F{Locat}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

2 个答案:

答案 0 :(得分:1)

在IReport 5.5.0错误字体未找到错误

 net.sf.jasperreports.engine.util.JRFontNotFoundException: Font '
                net/sf/jasperreports/fonts/pictonic/pictonic.ttf
                net/sf/jasperreports/fonts/pictonic/pictonic.svg
                net/sf/jasperreports/fonts/pictonic/pictonic.eot
                net/sf/jasperreports/fonts/pictonic/pictonic

我改为使用IReport 4.0.1

答案 1 :(得分:0)

验证您的类路径和服务器运行时间,并确保没有重复的jar包含不同的版本。