How to create Reports with extra resources
This tutorial explains how to generate Reports that need extra resources to be generated, such as XML adapters for JDBC connections, sub reports, custom fonts etc.
Â
Creating the Report
Â
Since version 1.6-Empire, if you create a Report template in the platform, you are going to notice some changes in the UI:
Â
Â
Report template is the main JRXML template, while additional resources can be any resource that the main reports needs to be generated.
Â
So for example, if we need to generate a Report that has subreports defined in it, we will upload all compiled subreports (.jasper) as additional resources:
This resources can be updated/removed at any time.
The same applies if your Report template needs an XML definition for your Web Service/JDBC connector:
Â
Particular case: Fonts
Â
Fonts need to be packetized inside a jar, you can take a look at the structure here:
http://jasperreports.sourceforge.net/sample.reference/fonts/#fonts
Â
Basically a structure as follows:
Â
Â
In the jasperreports_extension.properties you define where is the fonts.xml of your fonts:
Â
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.simple.font.families.dejavu=net/sf/jasperreports/fonts/fonts.xml
Â
fonts.xml: here you define where the compiler should find the fonts.
Â
While in the dejavu folder you have the fonts themselves, in a .ttf format
Â
When you have the jar, just upload it as an additional resource in your Report:
Â
Â
The JVM will find the fonts for your report without the need of installing the font in the System.
Â