Jasper Report模板中的Diacritic字符 [英] Diacritic chars in a Jasper Report template

查看:191
本文介绍了Jasper Report模板中的Diacritic字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用波兰语填写我的报告内容,因此我必须使用变音符号(±,ć,ę,ł,ó,ż,ź)。我遇到了问题,在将jasper打印输出到输出后跳过了它们。当我用模板lubiężółwie(意思是我喜欢乌龟用波兰语写)时,输出pdf只包含lubi wie(顺便说一句,他喜欢他知道 - 所以它变化很大;))。即使没有空白空间代替丢失的字母。他们只是跳过。

另外一个提示是,如果这些字符串是报表中的静态文本或动态 $ P {}

我试图(没有成功):
$ b


  1. 使用方法 setParameter(JRExporterParameter.CHARACTER_ENCODING,UTF-8) JRPdfExporter

  2. 设置 JRProperties.setProperty(net.sf.jasperreports.default.pdf.encoding ,UTF-8);

  3. 设置 JRProperties.setProperty(net.sf.jasperreports.export.character.encoding ,UTF-8);

  4. 将REPORT_LOCALE放入参数映射( JasperFillManager.fillReport






解决方案:对我而言将字体附加到类路径就足够了,请定义自己的jasperreports_extension.properties和fonts.xml。详情请此处。如果有人使用Grails框架来做到这一点(像我一样)这里更准确的例子。添加和需要的步骤是设置 JRProperties.setProperty(net.sf.jasperreports.default.pdf.encoding,Cp1250),正如Wojtek写道的。仍然不知道为什么,但当我知道答案时我会更新解决方案。 解决方案

如果您正在研究Windows机器:



在您的 JasperReports jar包内,您会找到一个名为 default.jasperreports 的配置文件,如下更改以下属性的值:

  net.sf.jasperreports.default.pdf.encoding = Cp1250 

您也可以使用:

JRProperties.setProperty(net.sf.jasperreports.default.pdf.encoding,Cp1250)



但我认为第一个解决方案更清洁请同时确保您的字段的 pdf字体支持变音字符,如Alex K所述。 AFAIK这些字体在字体选择组合框中加粗。



如果您想在报告中使用 UTF-8 字体,必须先将它们放置在您的类路径中并明确包含它们。


I have to use Polish language to fill my report content, so I have to use diacritic chars (ą, ć, ę, ł, ó, ż, ź). And I have problem with them, they are skipped after exporting jasper print to an output. When I write in a template "lubię żółwie" (means "I like turtles" in Polish), an output pdf contains only "lubi wie" (btw it means "he likes he knows" - so it changes a lot ;)). Even there are no empty spaces in place of missing letters. They are just skipped.

An additional hint is it doesn't matter if those string are static text in the report or dynamic $P{}

My question is: "How to make them appear"?

I was trying (without success):

  1. Using method setParameter(JRExporterParameter.CHARACTER_ENCODING, "UTF-8") of JRPdfExporter
  2. Setting JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "UTF-8");
  3. Setting JRProperties.setProperty("net.sf.jasperreports.export.character.encoding", "UTF-8");
  4. Putting REPORT_LOCALE into parameter map (JasperFillManager.fillReport)


SOLUTION: It turend out that in my case it's enough to attach a font to class path, define own jasperreports_extension.properties and fonts.xml. Details here. If somebody uses Grails framework to do it (like me) here is more accurate example. Addidtional and required step is setting JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250") as Wojtek wrote. Still don't know why but I'll update the solution when I know an answer.

解决方案

If you are working on a Windows machine:

Inside your JasperReports jar archive you will find a configuration file called default.jasperreports open it and change the value of the following property as follows:

net.sf.jasperreports.default.pdf.encoding=Cp1250

You can also use:

JRProperties.setProperty("net.sf.jasperreports.default.pdf.encoding", "Cp1250")

but I think the first solution is cleaner. Please also make sure that the pdf font of your field supports diacritic chars as Alex K noted. AFAIK those fonts are bolded out in the font selection combobox.

If you would like to use UTF-8 fonts with your report, you would have to place them on your classpath first and include them explicitly.

这篇关于Jasper Report模板中的Diacritic字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆