Anchors in JasperReport

Anchors in JasperReport

What is anchor?
Anchor provides easy access to different sections of the  report through link. One can implement this functionality in jasper using anchor expression in hyperlink. Anchor should always return ‘java.lang.String’ values.
While creating jasperreports we can use anchors in text field or image element component in the irpeort. Most important thing about these anchors is that they are also present in the pdf export of the report.

There are different types of anchor expression in ireport:

1. Local anchor: using this type of anchor expression one can tag the specific content in the report .

Example:
Creating a Local Anchor Example

 <textField>
<reportElement x="4" y="4" width="450" height="20"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String">"TITLE section"</textFieldExpression>
<anchorNameExpression>"title"</anchorNameExpression>
</textField>

The <anchorNameExpression> tag was used here in order to associate a local anchor, named title, with this text field.

Creating a Local Anchor Hyperlink Example

<textField hyperlinkType="LocalAnchor">
<reportElement x="4" y="40" width="400" height="20" forecolor="#FF0000"/>
<textFieldExpression class="java.lang.String">">> Click here to go to the title section."</textFieldExpression>
<hyperlinkAnchorExpression>"title"</hyperlinkAnchorExpression>
</textField>

The hyperlink created using the <hyperlinkAnchorExpression> tag points to the local anchor created above.

2. Local page: using this type of anchor expression one can tag the specific page in the report .

Creating a Local Page Hyperlink Example

<textField hyperlinkType="LocalPage">
<reportElement x="5" y="65" width="300" height="15" forecolor="#008000"/>
<textFieldExpression class="java.lang.String">"  >> Click here to go to the second page."</textFieldExpression>
<hyperlinkPageExpression>Integer.valueOf(2)</hyperlinkPageExpression>
</textField>

The hyperlink created using the <hyperlinkPageExpression> tag points to the second page of the current document.

3. Reference URL in the anchor: Using this anchor we can also put the URL in the report.

Creating a Reference Hyperlink Example

<textField hyperlinkType="Reference">
<reportElement x="5" y="95" width="300" height="15"/>
<textFieldExpression class="java.lang.String">"  >> Click here to go to www.google.com"</textFieldExpression>
<hyperlinkReferenceExpression>"http://www.google.com"</hyperlinkReferenceExpression>
</textField>

The hyperlink created using the <hyperlinkReferenceExpression> tag points to the www.google.com site.

4. Remote anchor hyperlink: The hyperlink created using the <hyperlinkReferenceExpression>and <hyperlinkAnchorExpression> tags points to an anchor named ‘title’ found in the HyperlinkReport.pdf document, saved in the current directory.

Creating a Remote Anchor Hyperlink Example

<textField hyperlinkType="RemoteAnchor">
<reportElement x="5" y="125" width="350" height="15"/>
<textFieldExpression class="java.lang.String">"  >> Click here to go to another PDF file."</textFieldExpression>
<hyperlinkReferenceExpression>"./HyperlinkReport.pdf"</hyperlinkReferenceExpression>
<hyperlinkAnchorExpression>"title"</hyperlinkAnchorExpression>
</textField>

 
5.  Remote page hyperlink:
The hyperlink created using the <hyperlinkReferenceExpression> and <hyperlinkPageExpression> tags points to the second page of the HyperlinkReport.pdf document, saved in the current directory.

Creating a Remote Page Hyperlink Example

<textField hyperlinkType="RemoteAnchor">
<reportElement x="5" y="125" width="350" height="15"/>
<textFieldExpression class="java.lang.String">"  >> Click here to go to another PDF file."</textFieldExpression>
<hyperlinkReferenceExpression>"./HyperlinkReport.pdf"</hyperlinkReferenceExpression>
<hyperlinkPageExpression>Integer.valueOf(2)</hyperlinkPageExpression>
</textField>

 
Thanks,
Nisha Sahu

Jaspersoft 6.2 Features and Upgrades

Dear Jaspersoft Users,

In this blog we would be talking about the latest version of Jaspersoft i.e. Jaspersoft 6.2 new features.

a. Advanced multi-tenant server administration capabilities

Jaspersoft in its latest release is providing more options to for administration of a multi-tenant envrionment. There is an option through which administrator can export resources for a particular user (which includes option to export data sources, domains, adhoc views, reports, dashboards, scheduled report job, other resource files, sub-organizations, dependencies, permissions, attributes and values).

Below snapshot can be referred to see the UI for the above functionality.

Jaspersoft 6.3

Jaspersoft 6.2

While exporting and then importing for some other user, the other user may/may not have certain accesses and privileges. Based on that proper warning messages appear like shown below

Jaspersoft 6.3 Import Warnings

Jaspersoft 6.2Import Warnings

 

b. Dashboard Improvements

There are certain small incremental improvements which Jaspersoft is making to make their dashboarding experience better (even though there is still a long way to go). In the latest release, Jaspersoft has added the option to add images to the dashboard. This image can also be fetched from a certain web link as well.

Also with the latest release, it is possible to export a dashboard in pdf/image/ODT format. Phantomjs libraries have been used for achieving this functionality. The input filters option can also appear as a popup options on top of the dashboard.

Jaspersoft 6.3 Dashboard

Jaspersoft 6.3 Dashboard

also with latest version, it is possible to drill down into the same panel by clicking on any portion of the chart.

 

c. Advanced charting customization options

Jaspersoft enterprise version uses highcharts. High charts provides a lot of customization option of the charts via APIs. In the latest release of Jaspersoft, they have created certain UI to trigger and have customization option of the charts. Using this some of the customizations which can be done like color, orientation, labels, reset option and position, title text, subtext, legend, panning, hover etc.

There is also a hyperlink of more information which opens a wiki page of Jaspersoft with more details regarding customization.

Jaspersoft 6.3 Charts Customization

Jaspersoft 6.2 Charts Customization

 

d. New charts

Treemap new chart has been added inside Jaspersoft adhoc reporting feature. Below snapshot is a treemap chart.

Jaspersoft Treemap Chart

e. Master scheduler view

With the latest version, Jaspersoft has a page wherein the loggedin user can see how many jobs have been scheduled and he is also having the option to selectively enable/disable those jobs. One user can not see the details of other users email scheduled jobs.

f. Reporting Improvements

There have been certain improvement on the jaspesoft studio or report designing level as well. In Jasper studio now there is an option to add a custom visualization component, thus any javascript (like D3 charts also) can be added inside and used.

– Also there is geojson support inside tibco geoanalytics and geomaps

In a frame multiple elements can be added, and then on resizing the frame the other elements present inside it gets resized. The same can also be done for tables so that columns fit the table element. Previously resizing was a very tedious job and this is a welcome improvement.

Jaspersoft 6.3 studio

 

Please get in touch with us at [email protected] for any Jaspersoft, Pentaho, ETL related requirements or queries.

Thankyou