10 Replies Latest reply on Feb 23, 2012 9:07 PM by Marc Sewtz-Oracle

    Showing dynamic images in BI Publisher PDF report

    Roel Hartman
      I defined a RTF report layout in BI Publisher. Almost done, but one requirement missing...
      I should be able to include a dynamic image (so every "object" on the report has it's own image).
      At first I embedded the base64 converted image in the XML output, but then I am running into the 32K limit. (Small pictures render fine).
      Although Marc Sewtz sort of promised in June 2008 (!) : "One issue, which we'll address in the next version of Application Express, is the 32k limit on report columns." on his blogpost http://marcsewtz.blogspot.com/2008/06/one-question-about-pdf-printing-feature.html , it still not addressed.

      So I tried to embed the image in the report using a trick described on the forum (and BIP documentation), by embedding a dummy picture and set the "Alt-text" of the picture to
      (as an example) : url:{'http://www.oracleimg.com/us/assets/oralogo-small.gif'}.
      The strange thing is, that works fine for HTML Output and Excel output, but not for Word and PDF (why it does work for Excel and not for Word is very mysterious....). And of course I need a PDF output.

      I also tried to embed a FO snippet:
      <fo:block>
      <fo:external-graphic src="url:{'http://www.oracleimg.com/us/assets/oralogo-small.gif'}" />
      </fo:block>
      But that doesn't (seem to) work on any output...

      But
      <fo:block>
      <fo:external-graphic src="D:\Users\rhartman\Documents\PrintScreen Files\Screenshot004.jpg" />
      </fo:block>
      does produce the image on the PDF output.

      So who has an idea how to solve this issue?? You'll be rewarded with a lot of pionts ;-)

      TIA
      Roel
        • 1. Re: Showing dynamic images in BI Publisher PDF report
          TexasApexDeveloper
          Could you just define report on the BI Publisher side and allow it to do the heavy lifting and call report from APEX using a web service call in APEX?: http://tylermuth.wordpress.com/2008/03/31/call-bi-publisher-web-services-from-apex/

          Thank you,

          Tony Miller
          Webster, TX
          1 person found this helpful
          • 2. Re: Showing dynamic images in BI Publisher PDF report
            Roel Hartman
            It's a rather complex report and we already spend some (read: a lot) of time developing it the "standard" way. If there is no other feasible construction we might have to redo it - although then I need to have access to the BI Publisher builder (might be another hurdle).
            I guess, when using a webservice call I could send a tag that's over 32k (DB version = 10.2)...
            • 3. Re: Showing dynamic images in BI Publisher PDF report
              TexasApexDeveloper
              Understood.. Are the images on the file system or in the database? Why I am asking there is a thread out on the bi publisher forum dealing with APEX and this issue I believe:

              https://forums.oracle.com/forums/thread.jspa?messageID=10075403&#10075403

              BI Publisher Blog also showing an answer: https://blogs.oracle.com/xmlpublisher/entry/dynamic_images

              Thank you,

              Tony Miller
              Webster, TX
              1 person found this helpful
              • 4. Re: Showing dynamic images in BI Publisher PDF report
                Roel Hartman
                Eventually the images will be served from the database using some kind of display_image procedure. But for now, I try to get a static version running..
                I added an IMAGE_URL field in the query and that comes up in my XML (I am sure, because I also do show the URL itself).

                But neither of the next references work for PDF:
                url:{.//IMAGE_URL} -> works for HTML, Excel
                url:{*/IMAGE_URL} -> never works
                url:{/IMAGE_URL} -> works from HTMl, Excel

                I even removed the first static image (logo in the header), but that has no effect at all - apart from the fact it doesn't show up anymore ;-)

                Any other bright ideas are more than welcome ;-)
                • 5. Re: Showing dynamic images in BI Publisher PDF report
                  Carsten Czarski-Oracle
                  Hi Roel,

                  some time ago I posted a document about this in the german APEX community.
                  http://www.oracle.com/webfolder/technetwork/de/community/apex/tipps/pdf-dyn-images/index.html

                  Inside a report (a table) it worked for me with just url:{IMAGE_URL}

                  Does this help ..?

                  Best regards

                  .Carsten
                  • 6. Re: Showing dynamic images in BI Publisher PDF report
                    trent
                    Hi Roel,

                    I attempted to include an image a while back, but in the end it seemed like more trouble than it was worth, so the client asked to get rid of it. Also, I think there is a limitation of the size you can have for the blob, so I would start really small, until you get the right size. Beyond a certain size, the image doesn't appear. (I notice you mention this... there were some minor improvements in 4.x - it had an even smaller limitation in 3.2 i believe) I did have validation to make sure the photo upload was smaller than a certain size, but users being users, well yeah.....

                    Anyway, in the test rtf file i have in the project files, the field code is as follows:
                    <fo:instream-foreign-object content-type="image/jpg" xdofo:alt="An Image" ><xsl:value-of select=".//PHOTO"/></fo:instream-foreign-object>
                    Good luck ;)

                    Edited by: trent on Feb 17, 2012 9:45 AM

                    I believe this is the reference I used: https://blogs.oracle.com/xmlpublisher/entry/inserting_blobs_into_your_repo
                    1 person found this helpful
                    • 7. Re: Showing dynamic images in BI Publisher PDF report
                      Roel Hartman
                      Hi Carsten

                      That was exactly* I was looking for. Maybe I should Google more in German ;-)

                      The main problem was that I defined my image outside the first repeating group (that doesn't repeat, it's always just one object) - the first group is followed by 7 more.
                      Just like the "Name" (that's positioned outside the group in the document header), I positioned the image above the table representing the group.
                      Doing that, the "Name" is filled correctly, the Image only when the Output Format is Excel or HTML - not Word or PDF ... makes no sense but that's tje way it is.

                      After moving the image inside the group....it works great!

                      (One more thing...the image size is fixed to the image you use as "dummy". Is there any way to make that more flexible, because now some scaling happens...)???

                      @Trent: That was the way we initially did it, but when the size of the row exceeds 32K...you know what happens.. And even with a small image the 32K limit is hit easily

                      The way I use it now (very similar to Carsten's description) there is no limit....

                      Thank you all!


                      Roel
                      • 8. Re: Showing dynamic images in BI Publisher PDF report
                        trent
                        Oh yeah sweet as :) I never thought about inserting the http links to images (my interpretation is that is what that technique effectively does). Out of curiosity, do you (or Carsten) do anything to protect the images? i.e. by allowing them in the bip report, effectively open access?.... may not be a big issue in this case.
                        • 9. Re: Showing dynamic images in BI Publisher PDF report
                          Roel Hartman
                          You can just grant execute to the procedure that creates the http link. So when a malicious user should know the name and parameters of that procedure (which he normally doesn't) he can download all the images. But he can get them anyway by creating all the reports.

                          FYI I created a blogpost about this : http://roelhartman.blogspot.com/2012/02/create-pdf-document-containing-dynamic.html
                          • 10. Re: Showing dynamic images in BI Publisher PDF report
                            Marc Sewtz-Oracle
                            Hi Roel,

                            Looks like there are several techniques to deal with this issue, but in order to follow up on my original suggestion to reference base64 encoded images in your RTF templates, I have outlined a few steps to make this work with larger images here:

                            http://marcsewtz.blogspot.com/2012/02/dynamic-images-in-pdf-what-32k-limit.html

                            The 32k limit on report rows - as you've noted - is still in place, however in this example I'm generating the XML data without using the APEX reporting engine, and calling the APEX Print APIs directly instead. This gets me around that limit and allows for larger images. Not the perfect solution, but one more approach to get this to work.

                            Regards,
                            Marc