0 Replies Latest reply on Jul 23, 2019 10:31 AM by Doifode

    How to pass file location parameter to the java code for PDF merging API code(BI Publisher API)



      I need to merge the 2 or more PDF files and create a single PDF output to send it to respective party.

      I have created the class file XMLPublisher.class and passed the hard code locations.

      It is working in case of Hard code locations but I want to pass it as a parameter to the code.


      Can any one please help in regards to this.


      I  have posted the code with this.


      package oracle.apps;


      import java.io.File;

      import java.util.Properties;

      import oracle.apps.xdo.XDOException;

      import oracle.apps.xdo.common.pdf.util.PDFDocMerger;

      import java.io.IOException;

      import java.util.Enumeration;

      import java.util.Vector;

      import oracle.apps.fnd.common.ProfileStore;

      import oracle.apps.fnd.common.VersionInfo;

      import oracle.apps.fnd.cp.request.CpContext;

      import oracle.apps.fnd.cp.request.JavaConcurrentProgram;

      import oracle.apps.fnd.cp.request.LogFile;

      import oracle.apps.fnd.cp.request.OutFile;

      import oracle.apps.fnd.cp.request.ReqCompletion;

      import oracle.apps.fnd.cp.request.ReqDetails;

      import oracle.apps.fnd.util.NameValueType;

      import oracle.apps.fnd.util.ParameterList;



      public class XMLPublisher  implements JavaConcurrentProgram {


         public XMLPublisher() {}

         protected CpContext ctx;

        protected Vector params;

          private Properties env = new Properties();


        public void runProgram(CpContext paramCpContext)




            ctx = paramCpContext;      

            params = makeParamVector(ctx.getParameterList());





          catch (Exception localException)


            throw new RuntimeException(localException);



           private void setEnvironment()


        String inputFileOne = "/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/PDFDoc12.pdf";

        String inputFileTwo = "/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/PDFDoc13.pdf";

        String inputFileThree = "";


          String[] arrayOfString = {"inputFileOne","inputFileTwo","inputFileThree","outputFile"};


          for (int i = 0; i < arrayOfString.length; i++)


            String str = getParam(arrayOfString[i]);

            if (((str != null ? 1 : 0) & (!str.trim().equals("") ? 1 : 0)) != 0)


              env.setProperty(arrayOfString[i], str);





          private String getParam(String paramString)


          Enumeration localEnumeration = params.elements();

          while (localEnumeration.hasMoreElements())


            NameValueType localNameValueType = (NameValueType)localEnumeration.nextElement();

            if (localNameValueType.getName().equals(paramString))

              return localNameValueType.getValue();


          return "";



          private void run(){



        String inputFileOne=getParam("inputFileOne");//"/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/PDFDoc1.pdf";

        String inputFileTwo=getParam("inputFileTwo");//"/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/PDFDoc2.pdf";

        String inputFileThree=getParam("inputFileThree");//"/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/PDFDoc2.pdf"; 

        String outputFile=getParam("outputFile");//"/DEV1/oracle/apps/apps_st/comn/java/classes/oracle/apps/mergePDF.pdf";


      // Output destination of the merged PDF document.

      File outFile = new File(outputFile);    


      // PDF documents to be merged.

          File[] inpFiles = new File[3];

          inpFiles[0] = new File(inputFileOne);

          inpFiles[1] = new File(inputFileTwo);

      inpFiles[2] = new File(inputFileThree);


           // Create PDFDocMerger instance.

      System.out.println("Input file name"+inpFiles[0].getName());

      System.out.println("Input file name"+inpFiles[1].getName());

      System.out.println("Input file name"+inpFiles[2].getName());

          PDFDocMerger pdfMerger = new PDFDocMerger(inpFiles, outFile);



                  pdfMerger.setPageNumberCoordinates(300, 20);

      pdfMerger.setPageNumberFontInfo("Arial", 10);

      pdfMerger.setPageNumberValue(1, 1);


          // Run the merging process.




              }catch (XDOException e) {






          protected Vector makeParamVector(ParameterList paramParameterList)


          Vector localVector = new Vector();


          while (paramParameterList.hasMoreElements())




          return localVector;