Tuesday, May 26, 2015

BI Publisher API Example – Creating PDF Report from XML/RTF?

Oracle has shared us a set of BI Publisher Java Classes for performing various BI Publisher function like converting RTF to XSL-FO, generating PDF output from XSL-FO and XML etc.
In this post, we will generate a PDF output from XML file using the standard Oracle BI Publisher API’s (Java based).

STEP1: Prepare and Convert RTF template to XSL-FO file

Oracle have provided a Java Class to generate PDF output based on XSL-FO file and XML input. Hence, first step is to generate the XSL-FO file based on RTF template. Details are available in another article,
Now, we should be having a XSL-FO file.

STEP2: Prepare the Java wrapper Class for calling Standard class FOProcessor

import java.io.InputStream;
import java.io.OutputStream;
import oracle.apps.xdo.template.FOProcessor;
import oracle.apps.xdo.template.fo.util.FOUtility;
import java.io.*;
import oracle.apps.xdo.common.pdf.util.PDFDocMerger;
import oracle.apps.xdo.batch.DocumentProcessor;

public class convertxmltopdf {

  public static void main(String[] args)
      FOProcessor processor = new FOProcessor();
      processor.setData(args[0]); //input XML
      processor.setTemplate(args[1]);  //input XSL template
      processor.setOutput(args[2]); // output PDF File
          // Set output format (for PDF generation)
      // Start processing
    catch (Exception e)


STEP3: Compile the Java wrapper

javac -classpath $CLASSPATH convertxmltopdf.java

Step 4: Copy the Wrapper Class to JAVA_TOP

cp convertxmltopdf.class $JAVA_TOP

STEP5: Verify the Sample RTF template, XSL-FO file and XML File

Input XML:
Actual RTF:
Generated XSL-FO based on Step 1:

Step6: Place the XSL-FO and Input XML file in Desired Directory and Call the Wrapper Java Class

java -classpath $CLASSPATH convertxmltopdf ./INPUTDATAXML.xml ./RTFTEMPLATEEX.xsl ./RTFTEMPLATEEX.pdf

Output PDF:

1 Responses to “BI Publisher API Example – Creating PDF Report from XML/RTF?”

Sridevi K said...
October 7, 2016 at 10:55 PM

Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at training@oracleappstechnical.com | +91 - 9581017828.

Post a Comment


The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.