本文介绍了JasperReports - 字体扩展不起作用 - 导出为PDF时无法找到字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的网络应用中添加Tahoma字体到我的报告中。我使用字体扩展机制(通过iReport我已经导出扩展jar,并把它放在我的web应用lib目录)。我的font.xml文件如下所示:

 < fontFamily name =Tahoma> 
< normal><![CDATA [fonts / tahoma.ttf]]>< / normal>
< bold><![CDATA [fonts / tahomabd.ttf]]>< / bold>
< pdfEncoding><![CDATA [Cp1250]]>< / pdfEncoding>
< pdfEmbedded><![CDATA [true]]>< / pdfEmbedded>
< / fontFamily>

和我的风格:

 < style name =TAHOMA_FONTfontName =TahomapdfFontName =Tahoma/> 

问题是,当我尝试生成PDF时,发生以下错误:

iReports中不会发生此问题。另外,当我改变风格到下面的一个问题不会发生:

$ $ p $ < style name =TAHOMA_FONTfontName = TahomapdfFontName =fonts / tahoma.ttfpdfEncoding =Cp1250isPdfEmbedded =true/>

当我在net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory类中放置断点时,我可以看到Tahoma家族正在阅读。



我的jasperreports版本是3.7.4。



有什么建议吗? >

解决方案

这是我的问题。 font.xml定义很好,但风格定义不是。它应该是:

 < style name =TAHOMA_FONTfontName =Tahoma/> 

pdfFontName,pdfEncoding,isPdfEmbedded样式标签内的属性现在已被弃用,不应使用。 >

i am trying to add Tahoma font to my report in my web app. I use font extension mechanism (via iReport I've exported extension jar and put it in my web app lib directory). My font.xml file looks like this:

<fontFamily name="Tahoma">
   <normal><![CDATA[fonts/tahoma.ttf]]></normal>
   <bold><![CDATA[fonts/tahomabd.ttf]]></bold>
   <pdfEncoding><![CDATA[Cp1250]]></pdfEncoding>
   <pdfEmbedded><![CDATA[true]]></pdfEmbedded>
</fontFamily>

and my style:

<style name="TAHOMA_FONT" fontName="Tahoma" pdfFontName="Tahoma" />

The problem is that when I try to generate PDF the following error occurs:

This problem does not occur in iReports. Additionally when I change style to the following one the problem does not occur:

<style name="TAHOMA_FONT" fontName="Tahoma" pdfFontName="fonts/tahoma.ttf" pdfEncoding="Cp1250" isPdfEmbedded="true" />

When I put breakpoint in net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory class I can see that Tahoma family is being read.

My jasperreports version is 3.7.4.

Any suggestions?

解决方案

This was my problem. font.xml definition was fine but style definitions was not. It should be:

<style name="TAHOMA_FONT" fontName="Tahoma" />

pdfFontName, pdfEncoding, isPdfEmbedded attributes inside style tag are now deprecated and should not be used.

这篇关于JasperReports - 字体扩展不起作用 - 导出为PDF时无法找到字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 08:29