Using BIRT with Apex for PDF reports

One of the frequently asked questions in the Apex world is “How can I create a PDF report without BI Publisher”. The answers are always the same “use Apache FOP”, “use JasperReports”, but there is one solution that is not frequently given and that is “look at BIRT”. BIRT is an Eclipse-based open source reporting system for web applications, especially those based on Java and Java EE. BIRT has two main components: a report designer based on Eclipse, and a runtime component that you can add to your app server. BIRT also offers a charting engine that lets you add charts to your own application.

Installation

The BIRT site gives an excellent explanation how to install the Birt Report Designer in your Eclipse IDE or how to install a dedicated report designer, based on the same IDE. So no use for me to explain this. I will suffice to say that de report Designer is a Perspective within the IDE ( Window>Open Perspective > Other> Report Design).

The BIRT site also gives a lot of examples how to create a report. The report eventually will be a file with a rptdesign extension. In a nutshell, it goes like this:

  • Create a new project
  • Use as wizard the Business Intelligence and Reporting Tools > Report Project
  • Create a new report within the project using the appropriate template
  • Create the data source
  • Create the dataset
  • Drag and drop the dataset to the appropriate positions on the report
  • Do your layout thing
  • Save the report

Making a connection with Oracle

To create the data source that connects to an Oracle database you have to choose the JDBC Data Source option. However, after a fresh installation the Oracle Driver is not known yet. Click the button Manage Drivers…

making an connection

In the next screen you have to add the JAR file with the driver class. I had an ojdbc6.jar file from an Oracle client installation. As an alternative, if you have a JDeveloper or SQLDeveloper installation at hand, you should be able to find an ojdbcN.jar file.

After you added the JAR file, the Drivers tab will show you two extra drivers: oracle.jdbc.driver.OracleDriver and oracle.jdbc.OracleDriver. Edit the latter and fill in the template URL

edit driver

Now you can choose the Oracle driver in the data source creation wizard and you can fill in the right credentials

Runtime viewer

If you are like me you have always a Tomcat installation at hand. If not, it’s very simple to download at Apache Tomcat. On the BIRT-site you can download BIRT-runtime. From this zip-file, take the WebViewerExample and extract it to your Tomcat/webapps directory. Rename the directory to birt-viewer. Restart Tomcat and go to http://localhost:8080/ (or the dedicated Tomcatserver instead of localhost of course).
Choose the Manager. It should look something like this:

tomcat

Click the birt-viewer hyperlink and choose on the next page the View Example.

next page

But look at the URL

 http://localhost:8080/birt-viewer/frameset?__report=test.rptdesign&sample=my+parameter.

This gives us a clue how to integrate with Apex.

Your report must be copied to the birt-viewer root directory. Look in the BIRT documentation for the setting such that the servlet will look in an alternative location.

The ojdbcN.jar file you used within the IDE must be copied to the Tomcat/lib directory to enable the server to find the right driver. Restart Tomcat after you copied the file.

Integration with Apex

I created a simple report, connected as scott/tiger that selected everything from DEPT and with a parameter P_DEPTNO. The URL to test this report is

http://localhost:8080/birt-viewer/frameset?__report=departments.rptdesign&p_deptno=10&__format=pdf

The __format parameter in the URL controls, well, the format of course. You can also use values like doc and xls.

Knowing this, integration is rather trivial; just generate an hyperlink in any form that navigates to the URL with the right parameter(s).

8 thoughts on “Using BIRT with Apex for PDF reports

  1. This is great , but one Question does this product require license ?
    How does it differs from other BI product , for what requirement we should go for this by not choosing jasper reporting tool and all .

    Kindly! do let me know thanks .

    Nandini Thakur

    • The BIRT site states that BIRT is Open Source and Licensed under the Eclipse Public License. Why should you choose BIRT and not JasperSoft… Well, why should you choose a tool from brand A and not from brand B? I think it is a very good alternative and for me it is more intuitive than eg. JasperSoft. So that’s subjective. I don’t know what indicators make it quantifiable for you to say that BIRT is “better” than Jasper. You should look into both and take your pick.

  2. but where is the oracle/apex integration? both urls posting to localhost and usually there is no tomcat on an oracle server … or am i wrong?

    • You are not wrong, Look into Birt, With the Birt installation you implicitly install an application server. In my example I used the one started within/by eclipse. And for the integration I said ” just generate an hyperlink in any form that navigates to the URL with the right parameter(s).”

  3. I need to keep my TOMCAT/webapps folder so I can’t rename it as suggested. That being said, where do you suggest I unzip the WebViewerExample file? And don’t we have to deploy the birt.war file somewhere on the Tomcat web server? It is not clear to me the Tomcat deployment steps.
    I would think we need to:

    1. deploy the birt.war file somewhere (webapps)
    2. deploy file(s) related to WebViewerExample

    Thank you.

  4. Here’s where I think the confusion is:

    Currently read:
    From this zip-file, take the WebViewerExample and extract it to your Tomcat/webapps directory. Rename the directory to birt-viewer.

    Should read:
    From this zip-file, take the WebViewerExample directory and extract it to your Tomcat/webapps directory. Rename the WebViewerExample directory to birt-viewer.

    Thanks.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.