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.
Can you tell me more about this jar?
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"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With