We described in previous articles how to set up APEX printing with OC4J and how to design XLS-FO Report Layouts. But how does APEX store the Report Queries and Report Layouts sent as XML and XLST to the FO Processor to generate the PDF?
Report Queries are stored in the b view:
As we mentioned in previous articles, a cost-free solution to obtain printing in APEX are the XSL-FO report layouts. We explained the solution in several articles:
– Custom APEX PDF Printing. Editing XSL-FO report layouts
– More on PDF Printing and XSL-FO layouts
And we, ApexNinjas.com developed the ALGEN application that you can download and use to generate your own report layouts.
But a while ago we came across an alternative to XSL-FO report layouts. Dietmar Aust suggested using JasperReports to generate report printing in APEX in a post on his blog: ODTUG2009 PDF Printing. This article contains the presentation slides where he explains and details the integration of the open source Java reporting engine “JasperReports” into Oracle Application Express for PDF and RTF printing.
An APEX Interactive Report (IR) can be enabled to be downloaded as PDF. If you have a printing server installed with APEX, you can just edit the IR's "Printing Attributes", enable the PDF format from the "Downloads" section and the report can be downloaded as PDF from the IR's "Actions" menu:
But what if we are using a custom configuration for PDF printing and we created our own (Shared Components) Report Queries and Report Layouts? The custom PDF layouts created in this manner, depend only on the queries defined in Report Queries and not on the Interactive Reports dispayed in the page, even if they might have the same source. How do we synchronize the data from a filtered IR with a Report Query? You can see a working example on this situation here.
APEX reports can be fully customized and by "breaking" their default structure. By default, all reports have a classic table structure, like this:
But how do you customize reports to have more complex structure, like this:
In two previous articles we described a robust and low-cost PDF printing architecture for APEX, consisting in the OC4J application servers working as a FOP printing processor for XSL-FO. The downside of this printing configuration is the manual design of Apex Report Layouts and the lack of tools to automatize the design. ApexNinjas.com team has designed a simple, beta-style and rudimentary tool for this scope, called ALGEN.
The possibilities of APEX PDF printing configuration using XSL-FO templates are virtually infinite, but they can be reduced to these simple "must-have" features:
1. Customize the header and the footer of the PDF
2. Display paragraphs, tables and images in the PDF body
3. Add conditional display statements, that allow the rendering of the PDF elements depending on items from the APEX application.
As I’ve said before, you don’t need the all-to-expensive BI Publisher, if you need to print good-looking PDF from APEX. Carl Backstrom suggested using Cocoon as an alternative XSL-FO Processing Engine. Out choice is 100% Oracle and it was detailed in previous articles: OC4J (a robust version of Oracle Application Server) as a printing server which could “read” the XSL-FO that make up the APEX Report Layouts.
The important issue still remains: how do you customize the APEX Report Layouts, without the BI Publisher tools? Well, manually, of course and with lots of patience. Or you can use a tool like ALGEN (ApexLayoutGenerator), which is an APEX application developed by the ApexNinjas.com team to help visually create Report Layouts based on existing Report Queries. About ALGEN and how to use it, I’ll return in a future post.
APEX allows two versions of printing server configurations: standard, using a print server of your choice, or advanced, that requires BI Publisher. ApexNinjas.com gives you a simple and robust solution: APEX PDF printing using OC4J as a print server (on Linux Centos with Oracle XE).
Step 1. Install OC4J server
Install the OC4J server as described here in detail. Start the server as a service or daemon.
Step 2. Configure OC4J with APEX-FOP
Access OC4J Application Server control from http://yourserver:8888 (ex.: http://www.apexninjas.com:8888). Login with oc4jadmin and the password provided in step 1.