1 2 Previous Next 19 Replies Latest reply: Feb 8, 2013 12:58 PM by userKaren RSS

    Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat

    userKaren
      Been working on this for a while and now at a dead end hoping the experts can direct me to try something new. There is lots in the forums on blobs and displaying in reports and from it all I have gleaned that I need to encode the blob in Base64 and then use this code.

      <fo:instream-foreign-object content type="image/jpg">
      <xsl:value-of select="IMAGE_ELEMENT"/>
      </fo:instream-foreign-object>

      I use this function to encode a 9KB jpeg into a clob (and my jpegs will be less then 32K.

      function encode_base64(p_blob_in in blob) return clob is
      v_clob clob;
      v_result clob;
      v_offset integer;
      v_chunk_size binary_integer := (48 / 4) * 3;
      v_buffer_varchar varchar2(48);
      v_buffer_raw raw(48);
      begin
      if p_blob_in is null then
      return null;
      end if;
      dbms_lob.createtemporary(v_clob, true);
      v_offset := 1;
      for i in 1 .. ceil(dbms_lob.getlength(p_blob_in) / v_chunk_size) loop
      dbms_lob.read(p_blob_in, v_chunk_size, v_offset, v_buffer_raw);
      v_buffer_raw := utl_encode.base64_encode(v_buffer_raw);
      v_buffer_varchar := utl_raw.cast_to_varchar2(v_buffer_raw);
      dbms_lob.writeappend(v_clob, length(v_buffer_varchar), v_buffer_varchar);
      v_offset := v_offset + v_chunk_size;
      end loop;
      v_result := v_clob;
      dbms_lob.freetemporary(v_clob);
      return v_result;
      end encode_base64;

      The xml is simple:

      <?xml version="1.0" encoding="UTF-8"?>
      <ROWSET>
      <ROW>
      <IMAGE_NAME>Test</IMAGE_NAME>
      <IMAGE_MIME_TYPE> image/jpeg </IMAGE_MIME_TYPE>
      <IMAGE_ELEMENT>…lots lines of encoded data… </ IMAGE_ELEMENT >
      </ROW>
      </ROWSET>

      Then when I put all together using BI Publisher Desktop 11.1.1.6 in an rtf template and preview the pdf, the preview fails with a long message ( can provide the whole thing if requested) but starting with:
      java.lang.ArrayIndexOutOfBoundsException: 0
           at oracle.xdo.common.image.ImageReader.checkFormat(ImageReader.java:130)
           at oracle.xdo.common.image.ImageReader.analyze

      I suspect the base64 encoding may be the problem but I am out of my realm in trying to debug this. Any help would be most appreciated…sorry for the length of this.
        • 1. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
          AlexAnd
          look at Re: BLOB image in XML Publisher
          and code for Wf_Mail_Util.EncodeBLOB

          for me the code of Wf_Mail_Util.EncodeBLOB works fine and produce data for publisher

          if i save result as xml and load into bip desktop (11.1.1.5) then set
          >
          <fo:instream-foreign-object content type="image/jpg">
          <xsl:value-of select="IMAGE_ELEMENT"/>
          </fo:instream-foreign-object>
          {quot}
          that's work fine

          but in r12.1.1 concurrent completed with warning :(

          if your test with bip desktop and xml data fails then try another way for generating xml data


          --add
          but in r12.1.1 concurrent completed with warning :(
          resolved by
          E1: XMLP: RTF Templates Created Using BI Desktop v. 11 Do Not Work with EnterpriseOne 8.98.x [ID 1301148.1]
          Report Generation Fails Due to oracle.xdo.parser.v2.XPathException: Namespace prefix 'ref' used but not declared [ID 1337111.1]

          Edited by: AlexAnd on Jan 30, 2013 3:50 AM
          • 2. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
            userKaren
            I am grateful for your reply and was extremely excited to try it after weeks of trying to do this.
            However, our DBA cannot find the procedure WF_MAIL_UTIL.EncodeBLOB.

            He looked for this package and all references state that it is a part of Oracle E-Business Suite ... it is not include with the Oracle database and we can't find a way to download the package from Oracle. We are using the BI Publisher reporting as part of our APEX applications.

            Do you or anyone else have an idea of how we could get this package or if there are any other options to try?
            Thanks.
            • 3. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
              AlexAnd
              so i tried below code in apps r12 and that's ok for "<fo:instream-foreign-object content type="image/jpg">"
              but try it for your system
              function xxgetbase64(p_in_blob in blob) return clob is
                p_out_clob clob;
                rawdata    raw(32767);
                chunksize  integer;
                amount     binary_integer := 32767;
                position   integer := 1;
                base64raw  raw(32767);
                chunkcount binary_integer := 0;
                cbuffer    varchar2(32000);
              begin
                chunksize := 12288;
                amount    := dbms_lob.getlength(p_in_blob);
                if (chunksize < amount) then
                  chunkcount := round((amount / chunksize) + 0.5);
                else
                  chunkcount := 1;
                end if;
              
                dbms_lob.createtemporary(p_out_clob, true);
              
                for i in 1 .. chunkcount loop
                  dbms_lob.read(p_in_blob, chunksize, position, rawdata);
                  base64raw := utl_encode.base64_encode(rawdata);
                  cbuffer   := utl_raw.cast_to_varchar2(base64raw);
                  dbms_lob.writeappend(p_out_clob, dbms_lob.getlength(cbuffer), cbuffer);
                  position := position + chunksize;
                end loop;
                dbms_lob.writeappend(p_out_clob, 1, chr(10));
              
                return(p_out_clob);
              end;
              • 4. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                userKaren
                I thank you again for continuing to try to help me. However, I regret to say that this function does not work. The same error results (see below). It is hard to believe that this cannot be done with APEX and BI Publisher. I would think that other APEX users have the need to display images and do not have the E-Business Suite.
                What I am doing is very straightforward....a small jpeg stored as a blob in an Oracle table that needs to be dynamically displayed from a report in APEX----created with BI Publisher and an rtf template.

                If you have any other ideas, please send them..your help is appreciated.

                Java.lang.ArrayIndexOutOfBoundsException: 0
                     at oracle.xdo.common.image.ImageReader.checkFormat(ImageReader.java:130)
                     at oracle.xdo.common.image.ImageReader.analyze(ImageReader.java:314)
                     at oracle.xdo.common.image.ImageReader.load(ImageReader.java:510)
                     at oracle.xdo.generator.pdf.PDFGenerator.createPDFImageReference(PDFGenerator.java:3261)
                     at oracle.xdo.generator.pdf.PDFGenerator.getImage(PDFGenerator.java:3399)
                     at oracle.xdo.generator.pdf.PDFGenerator.getImage(PDFGenerator.java:3388)
                     at oracle.xdo.generator.ProxyStreamGenerator.getImage(ProxyStreamGenerator.java:121)
                     at oracle.xdo.template.fo.area.AreaTree.getImage(AreaTree.java:779)
                     at oracle.xdo.template.fo.area.InstreamForeignObjectArea.loadImage(InstreamForeignObjectArea.java:82)
                     at oracle.xdo.template.fo.area.InstreamForeignObjectArea.init(InstreamForeignObjectArea.java:151)
                     at oracle.xdo.template.fo.area.GraphicArea.<init>(GraphicArea.java:80)
                     at oracle.xdo.template.fo.area.InstreamForeignObjectArea.<init>(InstreamForeignObjectArea.java:51)
                     at oracle.xdo.template.fo.elements.FOInstreamForeignObject.doLayout(FOInstreamForeignObject.java:134)
                     at oracle.xdo.template.fo.elements.FOInline.doLayout(FOInline.java:147)
                     at oracle.xdo.template.fo.elements.FOInline.doLayout(FOInline.java:83)
                     at oracle.xdo.template.fo.elements.FOBlock.doLayout(FOBlock.java:330)
                     at oracle.xdo.template.fo.elements.FOBlock.doLayout(FOBlock.java:226)
                     at oracle.xdo.template.fo.elements.FOBlock.doLayout(FOBlock.java:140)
                     at oracle.xdo.template.fo.elements.FOFlow.doLayout(FOFlow.java:84)
                     at oracle.xdo.template.fo.elements.FormattingEngine.startLayout(FormattingEngine.java:250)
                     at oracle.xdo.template.fo.elements.FormattingEngine.run(FormattingEngine.java:141)
                     at oracle.xdo.template.fo.FOHandler.endElement(FOHandler.java:720)
                     at oracle.xdo.common.xml.XSLTHandler$EEEntry.sendEvent(XSLTHandler.java:595)
                     at oracle.xdo.common.xml.XSLTMerger.startElement(XSLTMerger.java:51)
                     at oracle.xdo11g.parser.v2.XMLContentHandler.startElement(XMLContentHandler.java:182)
                     at oracle.xdo11g.parser.v2.NonValidatingParser.parseElement(NonValidatingParser.java:1322)
                     at oracle.xdo11g.parser.v2.NonValidatingParser.parseRootElement(NonValidatingParser.java:366)
                     at oracle.xdo11g.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:312)
                     at oracle.xdo11g.parser.v2.XMLParser.parse(XMLParser.java:218)
                     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                     at java.lang.reflect.Method.invoke(Unknown Source)
                     at oracle.xdo.common.xml.XDOSAXParser.invokeParse(XDOSAXParser.java:166)
                     at oracle.xdo.common.xml.XDOSAXParser.parse(XDOSAXParser.java:122)
                     at oracle.xdo.template.fo.FOProcessingEngine.process(FOProcessingEngine.java:407)
                     at oracle.xdo.template.FOProcessor.generate(FOProcessor.java:1218)
                     at RTF2PDF2.runRTFto(RTF2PDF2.java:473)
                     at RTF2PDF2.runXDO(RTF2PDF2.java:337)
                     at RTF2PDF2.main(RTF2PDF2.java:230)
                • 5. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                  userKaren
                  I just found something that does not give me an error....however nothing comes out. I just get 2 blank pages.
                  To encoded to base64, I used a function called apex_web_service.blob2clobbase64
                  I am playing with sizes but it is not making a difference. If anyone has experienced what would create a blank page when displaying an image, please share.
                  Thanks.
                  • 6. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                    AlexAnd
                    >
                    I regret to say that this function does not work.
                    >
                    did you check this by plsql code in some ide like sql developer?

                    for me code works for apps r12 and embedded publisher


                    >
                    Java.lang.ArrayIndexOutOfBoundsException: 0
                    at oracle.xdo.common.image.ImageReader.checkFormat(ImageReader.java:130)
                    at oracle.xdo.common.image.ImageReader.analyze(ImageReader.java:314)
                    at oracle.xdo.common.image.ImageReader.load(ImageReader.java:510)
                    >
                    can you check will be error without "<fo:instream-foreign-object content type="image/jpg">" in rtf template
                    may be error in another place?

                    can you share sample xml output with image data and without ones and your rtf template? (use some free hosting and share link)
                    • 7. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                      userKaren
                      Your code for function xxgetbase64 compiles in pl/sql and produces an encoded image when I create an xml from APEX. But no image is produced when I load the xml into the rtf template. Not sure if this answers your first question.

                      I removed <fo:instream-foreign-object content type="image/jpg"> and ran it and do not get the error...only a blank page. Does that tell you anything?

                      I just got an account on apex.oracle.com but not seeing how I can upload a jpeg to it. Need to figure that out and get something set up for you to look at. However, apex.oracle.com is using a later version of APEX 4.2 and I am using APEX4.1 Not sure if this will cause different results.
                      • 8. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                        AlexAnd
                        >
                        I removed <fo:instream-foreign-object content type="image/jpg"> and ran it and do not get the error...only a blank page. Does that tell you anything?
                        >
                        what's extension of image? .jpg in blob?

                        it's for jpg
                        <fo:instream-foreign-object content-type="image/jpg" ><xsl:value-of select=".//IMAGE_ELEMENT"/></fo:instream-foreign-object>
                        it's must be in field(!)

                        for not .jpg
                        >
                        image/jpg is the MIME type of the image (other options might be: image/gif and image/png)
                        >
                        "Rendering an Image Retrieved from BLOB Data" in http://docs.oracle.com/cd/E10415_01/doc/bi.1013/e12187/T421739T481157.htm

                        and
                        >
                        can you share sample xml output with image data and without ones and your rtf template? (use some free hosting and share link)
                        >


                        helpful
                        https://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
                        • 9. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                          userKaren
                          It is a jpg and I have it coded correctly ...even tried a png but no different.

                          I will go through all the steps again and over the next few days and see if I can pinpoint something else by process of elimination. Will report my findings...thanks again for your help.
                          • 10. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                            AlexAnd
                            can you share sample xml output with image? (use some free hosting and share link)

                            because your test case can depend of version of bip desktop and office

                            try my test case from your side without changing - http://depositfiles.com/files/qqutory2o
                            as test you can try replace my image in xml to your and look at the result
                            • 11. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                              userKaren
                              Had to work on something else for a few days but back to this now. When I go to this site, http://depositfiles.com/files/qqutory2o, my virus y software blocks it and I can;t get in. It would be great to be able to compare the same image and xml file that works for you and see if I can get it to work for me.
                              However, not sure if you can put something on another site.
                              • 12. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                                AlexAnd
                                try http://andyblg.wordpress.com/?attachment_id=325
                                save as im.zip
                                or
                                save as -> change extension to .zip

                                or post link to some free file host
                                or orabrig@yandex.ru
                                • 13. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                                  userKaren
                                  I started over with a new jpg, a new rtf and used your code 'xxgetbase64' for encoding with your code for the image properties-\
                                  <fo:instream-foreign-object content-type="image/jpg" ><xsl:value-of select=".//THEIMAGE"/></fo:instream-foreign-object>

                                  Seemed like a miracle as the image appeared. The only think I can think of is that I never tried the combination of using xxgetbase64 with the .// in the xsl code as I tried so many different functions and at first did not use .// However, now after the image I get another 7 pages of the xml code. I am hoping there is an easy solution to this and hoping you might know what is wrong.

                                  You can see my 3 simple files at the link below. There is the jpg, the rtf and the xml.
                                  http://www2.potsdam.edu/collinkj/BIPUBLISHER/

                                  Thank you for your help on this.
                                  • 14. Re: Rendering a dynamic image(blob) in a BI Publisher Report via an RTF templat
                                    AlexAnd
                                    >
                                    You can see my 3 simple files at the link below. There is the jpg, the rtf and the xml.
                                    http://www2.potsdam.edu/collinkj/BIPUBLISHER/
                                    >
                                    test_xml.xml is correct with correct image (as in Signature.JPG)

                                    for image you use
                                    <fo:instream-foreign-object content-type="image/jpg" ><xsl:value-of select=".//THEIMAGE"/></fo:instream-foreign-object>
                                    it's correct
                                    but after this you use "<?THEIMAGE?>" in field, why?

                                    >
                                    However, now after the image I get another 7 pages of the xml code.
                                    >
                                    of course it's because after
                                    <fo:instream-foreign-object content-type="image/jpg" ><xsl:value-of select=".//THEIMAGE"/></fo:instream-foreign-object>
                                    you have
                                    <?THEIMAGE?>
                                    which output all of THEIMAGE element in xml.
                                    delete field for <?THEIMAGE?>

                                    and your template will have only one field for image
                                    1 2 Previous Next