1 2 Previous Next 24 Replies Latest reply: Jan 13, 2010 5:29 AM by 743711 RSS

    cannot open the pdf when using the xml publisher to generate rtf report

    user539616
      Hello Everyone,

      I followed the below link to generate a pdf using xml publisher in OAF.

      http://apps2fusion.com/at/ps/260-integrating-xml-publisher-and-oa-framework

      When i try to save the pdf and open it, i get the below error:

      Adobe Reader could not open the pdf because it is either not a supported file type or because the file has been damaged(for example, it was sent as an email attachment and wasn't correctly decoded).

      Below is the code in CO.


      public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
      {
      super.processFormRequest(pageContext, webBean);
      OAApplicationModule am= (OAApplicationModule)pageContext.getApplicationModule(webBean);

      String event = pageContext.getParameter("event");
      if("GenerateReport".equals(event))
      {
      // Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
      DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
      HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
      try {
      ServletOutputStream os = response.getOutputStream();

      // Set the Output Report File Name and Content Type
      String contentDisposition = "attachment;filename=EmpReport.pdf";
      response.setHeader("Content-Disposition",contentDisposition);
      response.setContentType("application/pdf");

      // Get the Data XML File as the XMLNode
      XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      xmlNode.print(outputStream);
      // System.out.println(outputStream.toString());//Testing the output by printing the contents in the outputstream.
      ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
      ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();

      // System.out.println("language is "+pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage());
      // System.out.println("country is "+pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().geCountry());
      //Generate the PDF Report.

      TemplateHelper.processTemplate(
      ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
      // APP_NAME,
      "PER",
      // TEMPLATE_CODE,
      "Emp_Template",
      // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
      "English",
      // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
      "United States",
      inputStream,
      TemplateHelper.OUTPUT_TYPE_PDF,
      null,
      pdfFile);

      // Write the PDF Report to the HttpServletResponse object and flush.
      byte[] b = pdfFile.toByteArray();
      response.setContentLength(b.length);
      os.write(b, 0, b.length);
      os.flush();
      os.close();
      pdfFile.flush();
      pdfFile.close();
      }
      catch(Exception e)
      {
      response.setContentType("application/pdf");
      throw new OAException(e.getMessage(), OAException.ERROR);
      }
      pageContext.setDocumentRendered(false);
      }
      }

      Any suggestions on this would be great!

      Thanks
      Kumar
        • 1. Re: cannot open the pdf when using the xml publisher to generate rtf report
          Reetesh Sharma
          Hi Kumar,

          Language should be "en" not English and territory should be US not "United States".

          I hope this will resolve your problem.

          Regards,
          Reetesh Sharma
          • 2. Re: cannot open the pdf when using the xml publisher to generate rtf report
            user539616
            Reetesh,

            Thanks for the response. Actually i used the below command for language but as it didn't work, i changed it to English.
            ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage()

            Now, i have used en and US like you specified but still i am getting the same error.

            Thanks
            • 3. Re: cannot open the pdf when using the xml publisher to generate rtf report
              Reetesh Sharma
              Hi Kumar,

              First please check while registering the Template you have selected and terriotory as US.

              Please check your page after registering from your apps instance also.

              Regards,
              Reetesh Sharma
              • 4. Re: cannot open the pdf when using the xml publisher to generate rtf report
                user539616
                Yes Reetesh,

                I have selected US as the territory. I have uploaded the page in apps and tested it and again i see the same error.

                Any furthur suggestions would be appreciatable.

                Thanks
                • 5. Re: cannot open the pdf when using the xml publisher to generate rtf report
                  743711
                  hi Reetesh

                  i have the same problem ,i can't open the PDF file and when i change from file from .pdf to .htm
                  i got this message

                  Internal Error, Contact System Administrator: No corresponding LOB data found :SELECT L.FILE_DATA FILE_DATA,DBMS_LOB.GETLENGTH(L.FILE_DATA) FILE_LENGTH, L.LANGUAGE LANGUAGE, L.TERRITORY TERRITORY, B.DEFAULT_LANGUAGE DEFAULT_LANGUAGE, B.DEFAULT_TERRITORY DEFAULT_TERRITORY,B.TEMPLATE_TYPE_CODE TEMPLATE_TYPE_CODE, B.USE_ALIAS_TABLE USE_ALIAS_TABLE, B.START_DATE START_DATE, B.END_DATE END_DATE, B.TEMPLATE_STATUS TEMPLATE_STATUS, B.USE_ALIAS_TABLE USE_ALIAS_TABLE, B.DS_APP_SHORT_NAME DS_APP_SHORT_NAME, B.DATA_SOURCE_CODE DATA_SOURCE_CODE, L.LOB_TYPE LOB_TYPE FROM XDO_LOBS L, XDO_TEMPLATES_B B WHERE L.APPLICATION_SHORT_NAME= :1 AND L.LOB_CODE = :2 AND L.APPLICATION_SHORT_NAME = B.APPLICATION_SHORT_NAME AND L.LOB_CODE = B.TEMPLATE_CODE AND (L.LOB_TYPE = 'TEMPLATE' OR L.LOB_TYPE = 'MLS_TEMPLATE') AND ( (L.LANGUAGE = :3 AND L.TERRITORY = :4) OR (L.LANGUAGE = :5 AND L.TERRITORY = :6) OR (L.LANGUAGE= B.DEFAULT_LANGUAGE AND L.TERRITORY= B.DEFAULT_TERRITORY ))


                  do you know what the reason for that
                  • 6. Re: cannot open the pdf when using the xml publisher to generate rtf report
                    GsrC
                    Hi Kumar;
                    The error that your getting is generic error to see the exact error message first change your output type from PDF to HTML. Then it will give you clear error message after fixing if it if you able to see/run report fine in HTML then change your output type back to PDF.



                    Hi user8910159:
                    For your issue it seems your passing wrong parameters to TemplateHelper.processTemplate() to cross check your template is uploaded properly or not run the query the you got in error text by passing parameters as follows.

                    1 - Application Shot Name
                    2 - Template code that you given in template registration process
                    3 - Language 'en'
                    4 - TERRITORY 'US'
                    5 - Language 'en'
                    6 - TERRITORY 'US'


                    --
                    GsrC
                    • 7. Re: cannot open the pdf when using the xml publisher to generate rtf report
                      user539616
                      Hello,

                      Thanks for the message. The below what i had and i changed it to as follows:

                      OLD:
                      String contentDisposition = "attachment;filename=PrintPage.pdf";
                      response.setHeader("Content-Disposition",contentDisposition);
                      response.setContentType("application/pdf");

                      NEW:
                      String contentDisposition = "attachment;filename=PrintPage.HTM";
                      response.setHeader("Content-Disposition",contentDisposition);
                      response.setContentType("application/HTML");

                      When i save the html file and open it, i get the following message.

                      \ts03\u00\app\ts03\common\admin\out\xdoV82ijHAEJs123009_0212596090.fo (The system cannot find the path specified)

                      Thanks
                      • 8. Re: cannot open the pdf when using the xml publisher to generate rtf report
                        user539616
                        Below is the code. Can you change so that that the output can be seen in HTML? I checked the language, country etc and they are fine.

                        super.processFormRequest(pageContext, webBean);
                        OAApplicationModule am= (OAApplicationModule)pageContext.getApplicationModule(webBean);

                        String event = pageContext.getParameter("event");
                        if("GenerateReport".equals(event))
                        {
                        // Get the HttpServletResponse object from the PageContext. The report output is written to HttpServletResponse.
                        DataObject sessionDictionary = (DataObject)pageContext.getNamedDataObject("_SessionParameters");
                        HttpServletResponse response = (HttpServletResponse)sessionDictionary.selectValue(null,"HttpServletResponse");
                        try {
                        ServletOutputStream os = response.getOutputStream();

                        // Set the Output Report File Name and Content Type
                        String contentDisposition = "attachment;filename=PrintPage.pdf";
                        response.setHeader("Content-Disposition",contentDisposition);
                        response.setContentType("application/pdf");

                        // Get the Data XML File as the XMLNode
                        XMLNode xmlNode = (XMLNode) am.invokeMethod("getEmpDataXML");
                        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                        // xmlNode.print(outputStream);
                        // System.out.println(outputStream.toString());//Testing the output by printing the contents in the outputstream.
                        ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
                        ByteArrayOutputStream pdfFile = new ByteArrayOutputStream();

                        // System.out.println("language is "+pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage());
                        // System.out.println("country is "+pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().geCountry());
                        //Generate the PDF Report.

                        TemplateHelper.processTemplate(
                        ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
                        // APP_NAME,
                        "PER",
                        // TEMPLATE_CODE,
                        "Emp_Template",
                        // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
                        "en",
                        // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
                        "US",
                        inputStream,
                        TemplateHelper.OUTPUT_TYPE_PDF,
                        null,
                        pdfFile);

                        // Write the PDF Report to the HttpServletResponse object and flush.
                        byte[] b = pdfFile.toByteArray();
                        response.setContentLength(b.length);
                        os.write(b, 0, b.length);
                        os.flush();
                        os.close();
                        pdfFile.flush();
                        pdfFile.close();
                        }
                        catch(Exception e)
                        {
                        response.setContentType("text/html");
                        throw new OAException(e.getMessage(), OAException.ERROR);
                        }
                        pageContext.setDocumentRendered(true);
                        }
                        }

                        Thanks
                        • 9. Re: cannot open the pdf when using the xml publisher to generate rtf report
                          GsrC
                          Hi;

                          change these statements
                          user539616 wrote:
                          // Set the Output Report File Name and Content Type
                          String contentDisposition = "attachment;filename=PrintPage.pdf";
                          String contentDisposition = "attachment;filename=PrintPage.html";

                          response.setContentType("application/pdf");
                          response.setContentType("application/html");


                          >
                          TemplateHelper.processTemplate(
                          ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
                          // APP_NAME,
                          "PER",
                          // TEMPLATE_CODE,
                          "Emp_Template",
                          // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
                          "en",
                          // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
                          "US",
                          inputStream,
                          TemplateHelper.OUTPUT_TYPE_PDF,
                          null,
                          pdfFile);
                          TemplateHelper.processTemplate(
                          ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getAppsContext(),
                          // APP_NAME,
                          "PER",
                          // TEMPLATE_CODE,
                          "Emp_Template",
                          // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getLanguage(),
                          "en",
                          // ((OADBTransactionImpl)pageContext.getApplicationModule(webBean).getOADBTransaction()).getUserLocale().getCountry(),
                          "US",
                          inputStream,
                          TemplateHelper.OUTPUT_TYPE_HTML,
                          null,
                          pdfFile);


                          --
                          GsrC
                          • 10. Re: cannot open the pdf when using the xml publisher to generate rtf report
                            743711
                            hi Reetesh

                            i have aproblem in L.LOB_TYPE = 'TEMPLATE' OR L.LOB_TYPE = 'MLS_TEMPLATE'


                            when i create new template the LOB_TYPE = TEMPLATE_SOURCE (i didn't choose it )
                            and if i change the type into 'MLS_TEMPLATE' or TEMPLATE then i must change the type of RTF file into .XSl

                            what can i do ??

                            thx

                            Edited by: user8910159 on Dec 31, 2009 6:14 AM
                            • 11. Re: cannot open the pdf when using the xml publisher to generate rtf report
                              GsrC
                              Hi user8910159;

                              How you’re uploading template? Specify steps.
                              user8910159 wrote:
                              and if i change the type into 'MLS_TEMPLATE' or TEMPLATE then i must change the type of RTF file into .XSl
                              how changing type?

                              --
                              GsrC
                              • 12. Re: cannot open the pdf when using the xml publisher to generate rtf report
                                743711
                                hi Reetesh,

                                thanks for your replay

                                my steps were:
                                1- create the .rtf file
                                2- enter the temp Name , Code
                                3- choose the Application , Data definition
                                4- type = RTF
                                5- Default output Type=PDF
                                6-language= English territory=United States and the upload .rtf file preview format= PDF


                                and after creating the template i went to table of LOBS in the database i found that that type LOB_CODE = TEMPLATE_SOURCE
                                and in the error i published before (select satatment where LOB_CODE=TEMPLATE or MLS_TEMPLATE)
                                so when it try to select my remplate to there was always error because mine has TEMPLATE_SOURCE as LOB_CODE
                                and the SELECT where LOB_CODE= TEMPLATE
                                and by the way i followed the steps of this link http://apps2fusion.com/at/ps/260-integrating-xml-publisher-and-oa-framework



                                thx
                                • 13. Re: cannot open the pdf when using the xml publisher to generate rtf report
                                  GsrC
                                  Hi;

                                  select * from xdo_lobs where LOB_CODE = :T_CODE

                                  once we create template it will create 2 records in XDO_LOBS with LOB_TYPE one as TEMPLATE_SOURCE and another as TEMPLATE.


                                  select * from XDO_TEMPLATES_B where TEMPLATE_CODE = :T_CODE

                                  this table should have one record.

                                  check this in your case.


                                  --
                                  GsrC
                                  • 14. Re: cannot open the pdf when using the xml publisher to generate rtf report
                                    743711
                                    hi;

                                    thx for your reply and i did what you tell me and

                                    1- in table xdo_lobs i found 2 record as you said but LOB_TYPE were XML_SAMPLE and TEMPLATE_SOURCE


                                    in the first record the language and territory both 00 XDO_FILE_TYPE=XML LOB_TYPE=XML_SAMPLE (why the LOB_TYPE is not TEMPLATE ????? )

                                    the other record have a correct data except for the territory = 00 also and XDO_FILE_TYPE=rtf-etext

                                    2- in table XDO_TEMPLATES_B i found one record as you said all the data init are correct

                                    thx

                                    Edited by: user8910159 on Jan 2, 2010 12:26 PM

                                    Edited by: user8910159 on Jan 2, 2010 12:29 PM
                                    1 2 Previous Next