使用iReport创建pdf时使用自定义字体 [英] Use custom fonts when creating pdf using iReport

查看:387
本文介绍了使用iReport创建pdf时使用自定义字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


iReport版本:3.7.1

iReport Version : 3.7.1

我以两种方式解决了这个问题。

I approached this problem in two ways.


我的第一种方法

我在 iReport 中创建一个 pdf 页面,我将其中一个字段(来自数据库)设置为a字体 Gujarati-Salarl (印度地区语言的字体)。

I am creating a pdf page in iReport and I have one of the fields (from database) set to a font Gujarati-Salarl (A font for a regional language of India).

此字体在<$ c $的字体列表中可用C> iReport的。
当我点击预览时,我得到所需的输出,字段为所需的字体样式。

This font is available in the font list of iReport. When I hit preview I get the desired output , with the field in the required font style.

此处的所有内容都很好。

Everything till here is fine.

但生成的 pdf 文件仍包含相同的英文原始字体。

But the pdf file generated still contains the same original font in English characters.

无论是从应用程序调用报告还是从 JAVA 文件调用报告,结果都是一样的。

The result is same whether i call the report from the application or from a JAVA file.


经过一番研究后我发现了这个,第二种方法



JRProperties.setProperty("net.sf.jasperreports.default.pdf.font.name", "C:\\Gujrati-Saral-1.ttf");

这会将 pdf 的字体设置为提供了 ttf 字体,但现在整个 pdf 都有Guarati-saral字体,这不是我要找的..

This sets the font of the pdf to the ttf font provided but now the entire pdf comes in the Guarati-saral font which is not what I am looking for..

有没有办法将此字体专门应用于该特定字段?

Is there a way to specifically apply this font only to that one particular field?

当使用第二种方法时,有没有办法不将字体 Guarati-saral 应用到除所需字段之外的所有其他字段?

when going by the second method is there a way to not applying the font Guarati-saral to all other fields except the required one ?

推荐答案

您应该使用字体扩展机制。

创建字体并将其作为jar文件导出后,应将生成的jar文件添加到应用程序类路径中。

After creating the font and exporting it as a jar file you should add generated jar file to the application classpath.

a)在 iReport 中创建新字体(通过选项 - >字体 - >安装字体按钮)

a) Creating new font in iReport (via Options -> Fonts -> "Install Font" Button)

b)在iReport中将新字体(或现有字体)导出为jar文件(通过选项 - >字体 - >导出为扩展名按钮)

a)在 JasperReports Studio中创建新字体(通过窗口 - >首选项 - > JasperStudio - >字体 - >添加按钮)

a) Creating new font in JasperReports Studio (via Window -> Preferences -> JasperStudio -> Fonts -> "Add" Button)

b)配置字体

c)用你的字体创建JAR

您可以找到有关使用字体扩展名<的更多信息/ code> 此处

这篇关于使用iReport创建pdf时使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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