Talk:ADempiere/Compiere JasperReports Integration HowTo

From ADempiere
Jump to: navigation, search
This Wiki is read-only for reference purposes to avoid broken links.

Deprecated

  • This tutorial is now outdated due to recent enhancements to this in ADempiere by our bazaar team.
  • You merely need to create a new folder under ADEMPIERE_HOME i.e. /reports and placed your jasper file there.
  • ADempiere already set path to ADEMPIERE_HOME/reports so you need not set any further path unless you want to give a fully qualified path (in case something is wrong with the preset path).
  • Will update with a proper howto on this later.
- Red1 21:34, 20 July 2008 (EDT)
  • Hi, Red1. The outdated text also confused me. Now I've updated some contents according to my jasperreports implementation in Chinese.
- Peanut Blake DEC 22, 2010.

iReport Version

  • The IReport version to use for compiling your jrxmls should be 2.0.4 or else they don't seem to load during execution from ADempiere. The latest IReport 3.0 has that issue. Perhaps when we upgrade the jars to later versions they can work. - Red1 08:01, 21 July 2008 (EDT)

Upgraded to Version 3.0

  • It seems that the trunk has latest version of JasperRpt jars. So you can compile your jrxmls using version 3.0 - Red1 07:47, 25 July 2008 (EDT)

ADempiere 3.6.0 LTS upgraded to Version 3.7.3

  • ADempiere 3.6.0 LTS integrated version 3.7.3 JasperRpt jars. So you can compile your jrxmls using version 3.7.3 - Peanut Blake DEC 22, 2010.

Outdated Text

Removed on DEC 22, 2010

Here are the outdated text in the wiki page. I remove it because it may confuse users. Also new method has been written down. --Peanut Blake DEC 22, 2010.

Part 1

/== Parameters ==

When you run an Application Server Deployment, and you have a Subreport, then the Parameter SUBREPORT_DIR for establishing the location of the subreport must have a value like the one described in the section "Deploy reports on the application server":http://adempiereservename.domain/webApp/standalone.jrxml, or http://adempiereservename.domain:adempierewebport/webApp/standalone.jrxml, if the web port is other than 80.

Part 2

/==Problem with subreports==

When you have a report which contain a subreport into, you need to use the last with the compiled files (it’s .jasper file). Sometimes, if you use iReport to compile/edit your reports, maybe you compile the subreport with this tool. When you test the report from iReport, it work fine; but when you run the report from ADempiere, you can’t see nothing.

JRI Process Output.png

...and the report is not displayed.

Please take a look into the Preference > Errors window, and you can see something like:

JRI Error Subreports.png

And from the console as:

14:06:24.109 ReportStarter.addProcessParameters:  [13]
14:06:24.109 ReportStarter.httpDownloadedReport:  report deployed to http://work/webApp/Socios.jrxml  [13]
14:06:24.140 ReportStarter.isRequestedonAS: Got work/192.168.0.55 for http://work/webApp/Socios.jrxml as address 
             #0 [13]
14:06:24.140 ReportStarter.isRequestedonAS: Requested report is on application server host [13]
14:06:24.140 ReportStarter.isMD5HomeInterfaceAvailable: EJB client for MD5 remote hashing is present [13]
14:06:24.343 ReportStarter.ejbGetRemoteMD5: MD5 for http://work/webApp/Socios.jrxml is lumYIJ3VWbVpCtoOaF7Ftg== 
             [13]
14:06:24.343 ReportStarter.httpDownloadedReport: MD5 for local file is lumYIJ3VWbVpCtoOaF7Ftg== [13]
14:06:24.343 ReportStarter.httpDownloadedReport:  no need to download: local report is up-to-date [13]
14:06:24.343 ReportStarter.processReport: reportFile.getAbsolutePath() = C:\DOCUME~1\ALEJAN~1\CONFIG~1\Temp\Socios.
             jrxml [13]
14:06:24.343 ReportStarter.processReport:  no need to compile use C:\DOCUME~1\ALEJAN~1\CONFIG~1\Temp\Socios.jasper 
             [13]
===========> ReportStarter.startProcess: ReportStarter.startProcess: Can not run report -
             Error loading object from URL : http://work/webApp/Socios1.jasper [13]

But the compiled subreport file is there!

  • Note: the source files for JasperReports have .jrxml extension, and the compiled files have .jasper extension.

Ok, we will see some steps you can do to resolve the problem.

In the example we have a report, called Socios.jrxml and a subreport called Socios1.jasper (as compiled file; the source file is Socios1.jrxml). When we run the report from iReport, we can see the report is working and displayed ok:

JRI ReportViewer iReport.png

Note: You can see the report in blue colour, and the subreport in red colour.

The sources files (from iReport) are:

JRI Report Source jrxml.png
JRI Subreport Source jrxml.png

In summary, what we'll do is compile the subreport into ADempiere.


Then, we go by steps:

  • Step 1: Create a new process for the subreport

Login into ADempiere with System Administrator role, then go to Report & Process and add a new Record:

JRI Report&Process Subreport.png

fill the fields, but in the JasperReport field you will fill with the subreport source file name (in our example: Socios1.jrxml).'Save and close the window.

  • Step 2: Add to Menu the new process

Go to the Menu window and add a new record:

JRI Menu Add subreport.png

fill as a normal report and Save.

  • Step 3: Run the new report

Logout and login again, then you will see the new process recently created:

JRI Menu New Process Only.png

Ok, now run the Only for compile subreport process...

JRI Process Subreport Run.png

press Ok to start...

JRI Subreport Out.png

...then you can see the subreport output. Here the data is not important, the issue is when you ran the process, the subreport was compiled!

  • Step 4: Copy the new subreport compiled file

Now you must copy the new compiled file to the location as you need. In the example we will copy

From: C:\Documents and Settings\Alejandro\Configuración local\Temp\

JRI Copy Subreport Compiled.png

It's my Temp User folder.

To  : D:\Adempiere\jboss\server\adempiere\deploy\WebApp.ear\webApp.war\

JRI Paste Subreport Compiled.png

Note: the last is our http://adempiereservename.domain/webApp/ location; you must change for your.

  • Step 5: Test your Report

Ok, now we'll test the report...

JRI Menu Socios.png

then we'll run it..

JRI Report Subreport Ok.png

Ok, work fine now. It's all!

Part 3

/==Problems exporting to PDF==

If your report seems ok when opened with the swing viwer but it looks like gibberish when you export it to pdf check the following:

1. fontName is the same as pdfFontName in your report.

2. PDF Encoding - on every text field in your report there is a property PDF Encoding make sure that it is correct. For example if the text on your report is in Cyrillic most likely the correct value would be CP1251 (Cyrillic).

3. The font specified in pdfFontName is somewhere where jasperreports can find it or you specify the full name to the font. For example if I want to use Arial as the pdfFontName in my jasperreport then I will have as pdfFontName C:\Windows\Fonts\Arial.ttf If you are looking for an OS neutral solution you may add the font to your WebApp.war alongwith the .jrxml file and specify as pdfFontName the fullpath to it. For example if I have placed arial.ttf in WebApp.war then I will specify as pdfFontName something like: http://192.168.2.109:8080/WebApp/arial.ttf. If you are going to deploy your fonts on the webserver a good tip for managing the path to the reports is to create a style (look in the bottom right corner in iReport and click on Styles Library and click the right mouse button and then create style). In the created style specify your font and pdf font name (Font property) and then assign the style to all fields on your report. If your later need to change the font or the path to it you simply do it in the style.