jasperrepots-fonts jar 是什么以及如何使用它? [英] What is the jasperrepots-fonts jar for and how to use it?

查看:36
本文介绍了jasperrepots-fonts jar 是什么以及如何使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在评估 JasperReports 以生成报告.我在 Windows 和 Linux 之间的报告可移植性方面遇到了一些问题.我找到了一个(hacky)解决方案来让它跨平台工作.但是我想知道 jasperreports-fonts 是什么:

i'm evaluating JasperReports for report generation. I have some problems with report portability between Windows and Linux. I found a (hacky) solution to make it work cross platform. However i wonder what is the jasperreports-fonts for:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-fonts</artifactId>
    <version>5.6.1</version>
</dependency>

我看到它包含 DejaVu Sans 字体,但我不知道如何使用这个 jar(我在网上什么也没找到),以及这是否能以优雅、简单的方式解决我的跨平台软件问题.

I see that it contains the DejaVu Sans font but i have no idea how to use this jar (i found nothing on the net) and if this would solve my cross platform soft in an elegant, simple way.

你能告诉我更多关于这个罐子的信息吗?

Can you tell me more about this jar?

推荐答案

在 jasper 报告(.jrxml 文件)中,您可以使用多种字体来显示标签/文本.这些字体在不同的平台/操作系统上可能并不总是可用.(例如,有些 MS 字体在 linux 机器上不可用,除非您手动安装它们).因此,我们将 jasper report 中使用的字体捆绑到一个 jar 中,并使它们无论底层平台如何都可以工作.此外,您可以在字体扩展 jar 中包含您自己的(自定义创建的)字体,并将它们与 jasper 报告一起发送.更多信息在此处.

In jasper report (.jrxml file) you can use several fonts for displaying labels/texts. These fonts may not be always available on different platforms/OS. (e.g. There are some MS fonts which are unavailable on linux machines unless you install them manually). So, we bundle the fonts used in jasper report into a jar and make them work irrespective of underlying platform. Additionally, you can include your own (custom created) fonts in fonts extension jar and ship them along with jasper reports. More information is here.

还有几种方法可以配置和使用这个 jar.看看 这个了解一种最简单的方法.

Also there are couple of ways to configure and use this jar. Have a look at this to know one of the easiest way.

注意如果jrxml中使用的字体在JVM中不可用,导出报告时会报错如下:

Note that if the font used in jrxml is not available in the JVM, it will throw an error while exporting the report as follows:

net.sf.jasperreports.engine.util.JRFontNotFoundException:  
   Font 'Arial' is not available to the JVM.   

这可以通过两种方式解决:
1. 使用 jasperreport-extension.jar 或
2. 将属性 net.sf.jasperreports.awt.ignore.missing.font 设置为 true 以忽略丢失的字体.例如在jrxml中可以这样设置:

This can be solved in 2 ways:
1. Use jasperreport-extension.jar OR
2. Set the property net.sf.jasperreports.awt.ignore.missing.font to true to ignore missing font. e.g. In jrxml, you can set it as follows:

<property name="net.sf.jasperreports.awt.ignore.missing.font" value="true"/>

这篇关于jasperrepots-fonts jar 是什么以及如何使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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