报告中条形码的字体扩展名

时间:2012-08-24 07:17:05

标签: jasper-reports

我想将 Barcode font39 添加到我的 JR 报告中。正如 JasperReports 教程中所述,我已经打包了 fonts.xml .ttf jasperreports_extension.properties 在jar中并在classpath中包含此jar。

我的 fonts.xml 内容如下:

<fontFamilies>
    <fontFamily name="Barcode">
        <normal>net/sf/jasperreports/fonts/barcode/ConnectCode39_S3_Trial.ttf</normal>
        <pdfEncoding>Identity-H</pdfEncoding>
        <pdfEmbedded>true</pdfEmbedded>
    </fontFamily>
</fontFamilies>

jasperreports_extension.properties 文件:

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.myFamily=net/sf/jasperreports/fonts/fonts.xml

然而,当运行时,我得到以下异常:

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:77)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
    at net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
    at net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
    at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:52)
    at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
    at Report.Test.main(Test.java:213)
Caused by: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Input stream not found at : net/sf/jasperreports/fonts/fonts.xml
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:156)
    at net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:55)
    at net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
    at net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83)
    ... 8 more
Caused by: net.sf.jasperreports.engine.JRException: Input stream not found at : net/sf/jasperreports/fonts/fonts.xml
    at net.sf.jasperreports.repo.RepositoryUtil.getInputStream(RepositoryUtil.java:169)
    at net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:151)
    ... 11 more

我做错了什么?

0 个答案:

没有答案