The main purpose of this article is to provide a sample of custom ad-hoc template to display logo/image in generated ad-hoc report in JasperReports Server v.5.5 +
As mentioned in JasperReports Server Admin guide, JasperReports Server5.5 introduced Ad Hoc templates and report generators. Ad Hoc templates are JRXML files in the repository that define the format for reports generated from Ad Hoc views:
Attached are 2 custom ad-hoc templates based on 'Actual Size' template (/public/templates/actual_size.510.jrxml) which shipes with JasperReports Server.
The first custom template (logo_in_title.jrxml) displays an image from repository in report Title band. The following code added to the end of the template:
<title> <band height="51"> <image> <reportElement x="0" y="0" width="551" height="51"/> <imageExpression> <![CDATA["repo:/public/Samples/Resources/Images/Jaspersoft_logo.png"]]> </imageExpression> </image> </band> </title>
With this template, Title band definition 'overrides' the default one and as a result, ad-hoc Title defined in ad-hoc designer is lost
If you need to display ad-hoc view title in the report, the logo can de displayed in report's pageHeader band as implemented in the second template (logo_in_pageHeader.jrxml):
<pageHeader> <band height="51"> <image> <reportElement x="0" y="0" width="551" height="51"/> <imageExpression> <![CDATA["repo:/public/Samples/Resources/Images/Jaspersoft_logo.png"]]> </imageExpression> </image> </band> </pageHeader>
Below is the template applying result:
In order to use the custom templates, they have to be upload to JasperReports Server repository, Public > Templates folder.
UPDATE: in case of using Ad Hoc View with Chart, additonal steps should be done, please review the article below:
How to Change the Default Band Used for Ad Hoc Chart Reports from 'Title' to 'Summary'?
CS #62621
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now