Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the jasperrepots-fonts jar for and how to use it?

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>

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.

enter image description here

Can you tell me more about this jar?

like image 968
Robert Niestroj Avatar asked Nov 28 '14 08:11

Robert Niestroj


1 Answers

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.

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

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.   

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"/>
like image 74
keenUser Avatar answered Sep 22 '22 00:09

keenUser