Creating a PDF report

In APEX it is possible to export the data to PDF (Portable Document Format) format. The PDF format is created by Adobe and is widely accepted as a standard. To be able to export to PDF format, you need a report server like BI Publisher, a Java application server like Tomcat or Oracle's Weblogic with Apache FOP or a standard XSL-FO processing engine. We will discuss the interaction with Oracle BI Publisher.

Getting ready

First you need to install Oracle BI Publisher. You can download it from Oracle.com. We downloaded version 10.1.3.4.1 for Windows.

Tip

Don't make the install path too long. Otherwise the installer will fail.

After downloading and unpacking, run setup.exe and follow the steps in the installer. After installing, try to run BI Publisher. You can find the relevant settings such as the BI Publisher admin screen URL with the username and password and the commands to start and stop BI Publisher in the file BI_Publisher_readme.txt, which you can find in<drive:>Orahome_1, where<drive:> is your local hard drive. By default, the URL is http://localhost:9704/xmlpserver if you installed BI Publisher on your own computer. If you installed BI Publisher on another computer, localhost must be replaced by the name of the other host. For this recipe, we will use the default hostname localhost and port 9704.

If the installation went OK, you should see something like the following screenshot:

Getting ready

The next step is to configure APEX for BI Publisher. Therefore, you have to log in to the internal workspace as administrator.

Getting ready
  1. If you don't know the password, ask your administrator. If the password is unknown, you can change it using the apxchpwd.sql script, which you can find in the APEX directory. You need to execute this script as the SYS user.
  2. After successful login, select Manage Instance.
  3. In the instance settings section, click the Instance settings link.
  4. In the report printing section, select Advanced (requires Oracle BI Publisher) in the Print server radio button.
  5. In the print server host address field, enter the name of the host where BI Publisher is installed. In our case, this is the local machine, so enter here localhost.
  6. In the print server port field, enter 9704. That is the default port number of BI Publisher. In the print server script field, enter /xmlpserver/convert.
  7. Click the Apply changes button. APEX is now configured for interaction with BI Publisher.

You should have an application with at least one report.

How to do it...

Now we will make a link below a report region which enables the user to export the report to PDF format.

  1. Go to the Report page.
  2. In the Regions section, click on the Report link.
  3. Click on the Print Attributes tab.
    How to do it...
  4. In the printing section, select Yes in the enable report printing list box.
  5. In the link label field, enter a name for the link.
  6. In the output format list box, select PDF.
  7. Click the Apply Changes button.
  8. The link is ready now. In the Regions section, you will see that there is a Print link behind the report region.
  9. Click Run to run the report.
  10. You will see a link below the report region. Click this link.
    How to do it...
  11. The result will be a pop-up window where the user can choose to save the report in PDF format or open the report using Adobe Reader. In the last case, you will see something like this:
    How to do it...

How it works...

When using the print link, APEX converts the data to an XML format and sends it to the BI Publisher engine. The convert script then converts it to PDF format and sends it back to APEX.

There's more...

The output shown is rather simple. Using BI Publisher and templates you can make more advanced and nice looking reports.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.119.170