3

我正在尝试通过 JasperReport 创建 PDF 报告,但读取字体数据存在问题。我在 ClassPath 中有 jasperreports_extension.properties 和相关的 TTF 文件。这是错误:

java.io.IOException: Problem reading font data.
    java.awt.Font.createFont(Font.java:924)
    net.sf.jasperreports.engine.fonts.SimpleFontFace.<init>(SimpleFontFace.java:69)
    net.sf.jasperreports.engine.fonts.SimpleFontFamily.createFontFace(SimpleFontFamily.java:316)
    net.sf.jasperreports.engine.fonts.SimpleFontFamily.setNormal(SimpleFontFamily.java:85)
    net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamily(SimpleFontExtensionHelper.java:243)
    net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.parseFontFamilies(SimpleFontExtensionHelper.java:214)
    net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:183)
    net.sf.jasperreports.engine.fonts.SimpleFontExtensionHelper.loadFontFamilies(SimpleFontExtensionHelper.java:152)
    net.sf.jasperreports.engine.fonts.FontExtensionsRegistry.getExtensions(FontExtensionsRegistry.java:55)
    net.sf.jasperreports.extensions.DefaultExtensionsRegistry.getExtensions(DefaultExtensionsRegistry.java:110)
    net.sf.jasperreports.engine.util.JRStyledTextParser.<clinit>(JRStyledTextParser.java:83)
    net.sf.jasperreports.engine.fill.JRBaseFiller.<init>(JRBaseFiller.java:121)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:77)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:87)
    net.sf.jasperreports.engine.fill.JRVerticalFiller.<init>(JRVerticalFiller.java:57)
    net.sf.jasperreports.engine.fill.JRFiller.createFiller(JRFiller.java:142)
    net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:78)
    net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:624)
    org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.fillReport(AbstractJasperReportsView.java:666)
    org.springframework.web.servlet.view.jasperreports.AbstractJasperReportsView.renderMergedOutputModel(AbstractJasperReportsView.java:559)
    org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
    org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1063)
    org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:801)
    org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

谁能帮帮我??

谢谢!

4

3 回答 3

2

更改对 tomcat 临时目录的权限以允许 tomcat/jasper 对其进行写入。

请参阅:http: //community.jaspersoft.com/questions/543492/javaioioexception-problem-reading-font-data

于 2014-02-20T23:21:27.243 回答
1

就我而言,我通过在 Tomcat 文件夹中手动创建临时目录并更改权限来解决此问题。

以管理员访问权限运行 tomcat/application server 也会有所帮助。

于 2016-01-05T07:26:22.600 回答
0

我面临同样的问题,在我的情况下,根本原因是从 tomcat 目录中删除了临时文件夹解决方案是当我在 tomcat 中创建临时文件夹时,这个问题就解决了。

于 2017-05-19T09:22:47.527 回答