Using JasperReports with a relative path

Paths must be absolute. Only compile .jrxml files to .jasper files if the .jrxml is being modified. Usually you can just load the .jasper file and skip compilation altogether. It is much faster. Store .jasper and .jrxml files outside of your web root. Create the following parameters throughout all your reports: ROOT_DIR = “/full/path/to/reports/” IMAGE_DIR … Read more

How to sum all values in a column in Jaspersoft iReport Designer?

It is quite easy to solve your task. You should create and use a new variable for summing values of the “Doctor Payment” column. In your case the variable can be declared like this: <variable name=”total” class=”java.lang.Integer” calculation=”Sum”> <variableExpression><![CDATA[$F{payment}]]></variableExpression> </variable> the Calculation type is Sum; the Reset type is Report; the Variable expression is $F{payment}, … Read more

How to display a svg byte array as an image in a JasperReport?

Custom Image Transcoder Write a custom image transcoder that can read an SVG file and transform that resource into a PNG or SVG file. When exporting as PDF, it is okay to use an SVG file directly. Consider: import java.awt.Color; import java.io.*; import net.sf.jasperreports.engine.JRException; import net.sf.jasperreports.engine.util.JRLoader; import org.apache.batik.transcoder.*; import static org.apache.batik.transcoder.image.ImageTranscoder.*; import org.apache.batik.transcoder.image.PNGTranscoder; public class … Read more

Multiple queries in a single jasper document

It is possible to use execute multiple queries from a single report by using a subDataset and datasetRun. The behaviour is like having one or more subreports embedded into a single report file. Define a subDataset like this: <subDataset name=”dataset1″> <parameter name=”someParam” class=”java.lang.String”/> <queryString><![CDATA[SELECT column1, column2 FROM table1 WHERE column1=$P!{someParam}]]></queryString> <field name=”column1″ class=”java.lang.String”/> <field name=”column2″ … Read more

How to show/hide a column at runtime?

In later version (v5 or above) of jasper reports you can use the jr:table component and truly achieve this (without the use of java code as using dynamic-jasper or dynamic-reports). The method is using a <printWhenExpression/> under the <jr:column/> Example Sample Data +—————-+——–+ | User | Rep | +—————-+——–+ | Jon Skeet | 854503 | … Read more

Font is not available to the JVM with Jasper Reports

I tried installing mscorefonts, but the package was installed and up-to-date. sudo apt-get update sudo apt-get install ttf-mscorefonts-installer I tried searching for the font in the filesystem, with: ls /usr/share/fonts/truetype/msttcorefonts/ This folder just had the README, with the correct instructions on how to install. cat /usr/share/fonts/truetype/msttcorefonts/README You need an internet connection for this: sudo apt-get … Read more