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

查看:600
本文介绍了什么是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报告中使用的字体捆绑到一个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天全站免登陆