Configuring JasperReports Library

JasperReports Server's reporting features are built on the JasperReports Library, which is embedded in the server. Many of the options you can configure to change the server's functionality are actually JasperReports Library options. The configuration options can control many aspects of the server's behavior, from the way reports are exported into different file formats, to the default font.

These options can be set at different levels:

Global – Applies to all reports generated by the server. Global JasperReports properties are defined in the .../WEB-INF/classes/jasperreports.properties file.
Report – Defined in the JRXML of the report and applies to that specific report.
Element – Defined in the JRXML and applies to specific elements of the report.

For more information about JasperReports Library configuration, see http://jasperreports.sourceforge.net/config.reference.html.

The following sections highlight a few of the available options:

Extending JasperReports Library
Changing the Crosstab Limit
Setting a Global Chart Theme
Disabling Interactivity in the Report Viewer
Disabling Chart Types in Dashboards
Enabling the XHTML or HTML Exporters
Changing the Pro Charts Rendering Engine
Configuring a JavaScript Engine for Graphical Report Rendering
Static Export Properties for High Charts
Enabling PDF Accessibility Features in Tables

Extending JasperReports Library

You can extend JasperReports Library by implementing the public interfaces it exposes.

Such an implementation is usually stored in a JAR (Java Archive) that contains a file called jasperreports_extension.properties, and specifies a factory class used to instantiate an extension registry. The extension registry specifies one or more extension objects, each of which corresponds to a JasperReports Library extension point represented by a Java interface.

Place this JAR on the JasperReports Library classpath, and your extension is automatically available.

For more information, refer to JasperReports Library Ultimate Guide.

Changing the Crosstab Limit

If you use crosstab reports, you may experience Out of Memory errors if the reports are very large or complex. You can configure JasperReports Server to return a message instead of memory errors when users run such crosstabs. To do so, enable the net.sf.jasperreports.crosstab.bucket.measure.limit property and set its maximum value in the following configuration file:

Crosstab Report Configuration Option

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

net.sf.jasperreports.
crosstab.bucket.
measure.limit

This value effectively limits the number of cells in a crosstab, which can be computed as follows:

(number of crosstab rows) x (number of crosstab columns) x (number of user-defined measures + 1)

The default value is 100000.

Enter large values to allow your users to create larger, more complicated crosstabs; enter small values to restrict them. If you experience OutOfMemoryExceptions after changing this value, try setting it to a smaller number, or configure your JVM to allow more memory to be used.

Setting a Global Chart Theme

Chart themes control the look and feel of the charts generated by JasperReports Server. Chart themes can be applied at the level of either the server or the individual report:

To apply a theme at the report level, select it when designing the report in Jaspersoft Studio. Note that you can also apply a theme to individual chart elements. Note that a chart theme can be included in a report unit as a resource. In this case the theme is available only to charts in that report unit.
To apply a theme at the server level, copy the chart theme JAR to the correct location and edit its configuration file.

A chart theme is a JAR file that defines the look and feel of a chart. Once you have created the chart theme JAR file, copy it to the .../WEB-INF/lib directory. Chart themes in this location are available to any chart in the instance of the server. They can also be set as the global chart theme.

To set a theme as the default chart theme, edit the following configuration file:

Global Report Theme

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

net.sf.jasperreports.
chart.ChartTheme

The name of a chart theme that is in the .../WEB-INF/lib directory.

We recommend that you create your chart themes in Jaspersoft Studio. Click File > New > Other > Chart Theme, then use Jaspersoft Studio to archive the new chart theme as a JAR.

Chart themes do not apply to Ad Hoc chart views.

Disabling Interactivity in the Report Viewer

By default, the report viewer's interactivity is enabled, and reports with interactive elements (such as the table component) are interactive when run in the web server and displayed in the viewer. If you don't want your reports to be interactive, you can disable interactivity across all reports by editing the following configuration file.

Interactivity in the Report Viewer

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

net.sf.jasperreports.
components.table.interactive

By default, this property is set to true; in this case, interactivity is enabled in the report viewer. Set it to false to disable interactivity.

Changing this setting in this configuration file changes the behavior for the entire server. To configure this behavior at the report, table, or column level, edit the report's JRXML properties in Jaspersoft Studio.

Disabling Chart Types in Dashboards

By default, interactivity is enabled in charts that appear in dashboards, and users can change the chart type by clicking on the chart type selector (gear icon). If you don't want users to modify the chart types, you can disable the chart type selector on all dashboard charts by editing the following configuration file.

Chart Type Selector in Dashboards

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

com.jaspersoft.jasperreports.
highcharts.interactive

By default, this property is set to true; in this case, chart types can be modified in dashboards. Set it to false to prevent users from changing dashboard charts.

Changing this setting in this configuration file changes the behavior for the entire server. To configure this behavior at the report level, edit the report's JRXML properties in Jaspersoft Studio.

Enabling the XHTML or HTML Exporters

By default, JasperReports Server exports HTML format using an HTML-based exporter. Unlike the default exporters from previous versions of the server (html and xhtml), the new HTML exporter (html2) is more forgiving when exporting reports that have overlapping elements while still preventing text from being cut off due to font metrics issues.

This setting affects all cases when HTML is exported, including when reports are exported from the report viewer and when they are scheduled to produce HTML output.

To use an older HTML exporter in JasperReports Server, edit the following configuration file:

HTML Exporters

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

com.jaspersoft.jasperreports.
export.html.type

Determines which of the HTML exporters is used. Valid values are:

html2 is the default HTML exporter. It handles overlapping report elements more gracefully than the other exporters.
xhtml was the default HTML exporter in versions from 4.5 to 5.0. We continue to support this exporter. It handles overlapping report elements more gracefully that the html exporter. However, it is subject to font metric mismatches between client browsers, which can result in text being cut off.
html was the default HTML exporter in versions of JasperReports Server before 4.2. Jaspersoft continues to support this exporter. It doesn't handle overlapping elements as gracefully as the other exporters.

Note that the properties are mutually exclusive; you can have only one uncommented at a time.

As of JasperReports Server version 5.5, if your reports include interactive elements such as the table component (which supports sorting and filtering in the HTML viewer), you must use the html2 exporter to enable the interactive features; the html and xhtml exporters don't support them.

Changing the Pro Charts Rendering Engine

By default, JasperReports Server renders Pro Charts (those based on Fusion Charts) using HTML5. If your browser doesn't support HTML5, the chart isn't be rendered unless you change the configuration. Though we don't recommend it, you can instead have these elements rendered by Adobe Flash; in some circumstances, Fusion's Flash solution may pose a security risk.

Note that Pro Charts are available only in the JasperReports Server Professional edition.

To render Pro Charts using HTML5, edit the following configuration file:

Pro Charts Renderer

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

com.jaspersoft.jasperreports.
fusion.charts.render.type

Determines which of the following renderers is used:

html5 is the default renderer for Pro Charts. It is our preferred renderer.
flash is a deprecated renderer for Pro Charts.

Note that this property applies only to reports that rely on Pro Charts and affects only the HTML preview and export.

Typically, this property is set at the server level; to override the server-level setting for a specific Pro Chart report, set this property at the report level, and also specify a second property as shown:

net.sf.jasperreports.print.transfer.fusion=com.jaspersoft.jasperreports.fusion

This allows the reporting engine, JasperReports Library, to recognize the Fusion settings. If this property isn't set, the com.jaspersoft.jasperreports.fusion.charts.render.type property is ignored at the report level.

Configuring a JavaScript Engine for Graphical Report Rendering

Depending on the circumstances, a given graphical element (such as a chart, a map, or a widget) in a report can be rendered in two ways:

When run directly in the web UI, the browser itself renders the chart.
When scheduled to run later or run in the background, an internal engine renders the chart.

By default, JasperReports Server's internal JavaScript engine is Rhino, which is an excellent solution for most cases; most JasperReports Server users can accept this default. However, you may want to investigate other engines if you encounter any of the following issues when scheduling chart-based reports or running them in the background:

Poor performance when generating complex charts or charts that contain large volumes of data.
Out of memory messages.
Incorrect scaling when certain Pro Chart reports are printed.
Results that don't match those generated when the report is run directly in the web UI. For example, text elements incorrectly sized or placed.

An alternative engine is provided in our installers; PhantomJS executes JavaScript when generating graphical reports that are run in the background or scheduled. PhantomJS is a headless WebKit with JavaScript API. To use PhantomJS when JasperReports Server is installed from the WAR file, download the correct version for your environment from PhantomJS and install it on the computer hosting JasperReports Server. For installation instructions, refer to the documentation provided with PhantomJS.

Once PhantomJS is installed, point JasperReports Server to its location. You can configure several processes to use PhantomJS: HighCharts generation, Pro Charts generation (including Pro Widgets and Pro Maps), and exporting dashboards.

These are a server-wide settings. In a given server, all charts of the same type (HighCharts or Fusion (Charts Pro, Maps Pro, or Widgets Pro) use the same JavaScript engine.

You can't use PhantomJS to render JFreeCharts. Such reports are always generated by Rhino when run in the background or scheduled.

To configure JasperReports Server to use PhantomJS for HighCharts and Pro Charts, including Pro Widgets and Pro Maps, edit the following properties:

JavaScript Engine Configuration for HighCharts and Pro Charts

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

net.sf.jaspersoft.jasperreports.
phantomjs.executable.path

This property points to the engine the server should use to generate HighCharts-based and Pro Charts-based charts in reports run in the background or scheduled.

For example, if you're using Windows and you expanded the PhantomJS 2.0 ZIP file into the root of your C: drive:

net.sf.jaspersoft.jasperreports.phantomjs.
executable.path=C:\\phantomjs-2.0-windows\\phantomjs.exe

com.jaspersoft.jasperreports.components.
customvisualization.phantomjs.executable.path
This property points to the engine the server should use for exporting Jaspersoft Studio reports with custom visualization components. See the Jaspersoft Studio User Guide for more information.

com.jaspersoft.jasperreports.
phantomjs.tempdir.path


The temporary directory where PhantomJS stores its output. By default, JasperReports Server expects this output in the location defined by Java's java.io.tmpdir system property.

com.jaspersoft.jasperreports.
phantomjs.executable.timeout

The maximum number of milliseconds to wait for output from PhantomJS before the chart times out. The default is 3000.

PhantomJS can also be used to render dashboards when exporting them to a PNG, PDF, ODT, or DOCX file. To support Japanese and Chinese fonts, as well as certain icons in dashboard output, Jaspersoft recommends using PhantomJS 2.0 or later.

If you are using JasperReports Server and PhantomJS on a Windows platform, exporting large Fusion reports may cause issues. In those cases, we recommend editing the properties as follows:

Change net.sf.jaspersoft.jasperreports.phantomjs.executable.path to com.jaspersoft.jasperreports.fusion.phantomjs.executable.path.
Set com.jaspersoft.jasperreports.fusion.phantomjs.executable.timeout to 600000 to increase the timeout period.

To configure JasperReports Server to use PhantomJS for exporting dashboards, edit the following property:

JavaScript Engine Configuration for Dashboards

Configuration File

.../WEB-INF/js.config.properties

Property

Description

phantomjs.binary

This property points to the engine the server should use to generate dashboards when exporting.

For example, if you are using Windows and you expanded the PhantomJS 2.0 ZIP file into the root of your C: drive:

phantomjs.binary=C:\\phantomjs-2.0-windows\\phantomjs.exe

After setting this property, restart JasperReports Server to enable it.

Static Export Properties for High Charts

When you create interactive JasperReports that use Highcharts, and those reports are exported to HTML, the <script> elements in the HTML must reference the correct JavaScript libraries. The following JasperReports Library properties define the library paths:

Static Export Properties for Highcharts

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

# Highcharts static export propertiescom.jaspersoft.jasperreports.highcharts.render.require.js$context.urlcom.jaspersoft.jasperreports.highcharts.jquery.js$context.urlcom.jaspersoft.jasperreports.highcharts.highcharts.js$context.urlcom.jaspersoft.jasperreports.highcharts.highcharts.more.js$context.urlcom.jaspersoft.jasperreports.highcharts.highcharts.heatmap.js$context.urlcom.jaspersoft.jasperreports.highcharts.data.service.js$context.urlcom.jaspersoft.jasperreports.highcharts.default.service.js$context.urlcom.jaspersoft.jasperreports.highcharts.item.hyperlink.service.js$context.urlcom.jaspersoft.jasperreports.highcharts.y.axis.service.js$context.urlcom.jaspersoft.jasperreports.highcharts.dual.pie.service.js$context.urlcom.jaspersoft.ji.adhoc.highcharts.setting.service.js$context.urlcom.jaspersoft.jasperreports.highcharts.highcharts.chart.producer.js$context.url<br />

Each property that ends in $context.url may also have a similar property ending in $url. The $context.url property is used when a request object is available to resolve a context path for the HTML export, and the $url property is used as a fallback.

Not all library paths are defined in the jasperreports.properties file. Some are provided by the environment (such as com.jaspersoft.jasperreports.highcharts.jquery.ui.js), and others are set programmatically by the bean com.jaspersoft.ji.adhoc.jr.AdhocHighchartsSetting-ServiceBundle (in the .../WEB-INF/applicationContext-adhoc.xml file).

Enabling PDF Accessibility Features in Tables

JasperReports Library supports properties and metadata that allow people to create accessible PDF documents that can be read by screen readers. These properties help meet the requirements specified in the Section 508c of the United States Rehabilitation Act of 1973.

In release 6.2, JasperReports Library now provides the ability to automatically add 508c metadata to table components. When this features is enabled, tables such as those in Ad Hoc reports and your own JasperReports contain the necessary metadata when exported to PDF.

Enabling PDF Accessibility Features in Tables

Configuration File

.../WEB-INF/classes/jasperreports.properties

Property

Description

net.sf.jasperreports.components.table.
generate.pdf.tags

When set to true, metadata for accessibility is automatically generated in JasperReports tables.

This property can also be set at the report level or table component level to control the automatically generated metadata.

Feedback