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.