X

An Oracle blog about BI Publisher

  • RTF
    May 2, 2006

Dynamic Images

Made it back from Nashville with a pile of requests for blog entries, I'll try and cover them over the next few weeks ... top of the list of requests was how to handle dynamic images in a layout template. There are several ways to tackle this depending on where your images are going to be at runtime. The scenario is, that I have three organizations in my company and they each have their own logo; at runtime, based on the organization I am generating a report for the output should show their logo. Lets assume we have the following XML data for all of these examples:


<INVOICELIST>
 <IMG_DIR>/images</IMG_DIR>
 <IMG_SERVER>http://xdo.us.oracle.com</IMG_SERVER>
 <IMG_DIR_PATH>c:temp</IMG_DIR_PATH>
 <G_VENDOR_NAME>
  <ORG>1</ORG>
  <IMGFILE>Org1.gif</IMGFILE>
  <VENDOR_NAME>Nuts and Bolts Limited</VENDOR_NAME>
  <ADDRESS>1 El Camino Real, Redwood City, CA 94065</ADDRESS>
   <G_INVOICE_NUM>
    <SET_OF_BOOKS_ID>124</SET_OF_BOOKS_ID>
    <GL_DATE>10-NOV-04</GL_DATE>
    ...
 </G_VENDOR_NAME>
 <G_VENDOR_NAME>
  <ORG>2</ORG>
  <IMGFILE>Org2.gif</IMGFILE>
  <VENDOR_NAME>Tick Tock Clocks</VENDOR_NAME>
  ...
</INVOICELIST>


So our XML references an image directory(IMG_DIR) on our server(IMG_SERVER) and the full path to the image directory (IMG_DIR_PATH) on our server, then each invoice has the organization ID and the image name to be used. So we can tackle this one of three ways:
1. Embed the three logos into the template directly
2. Reference the images on the disk and use a dynamic image
3. Reference the images via a URL


Embedding in the template


This is the simplest method, if we have three images, one for each organization we can add them all to the template and wrap them in conditional statements to show/hide them. 

DynImg1:

The simplest method is to use three 'if' statements, you could equally use a 'choose' statement to get the same effect. See DynamicImg1.rtf template here. If you have alot of images and/or need dynamic images in multiple templates; you could put a template function either else where in the template or ina completely separate template altogether and then call it from the main templates. See DynamicImg2.rtf for an example in the zip file


Using dynamic images


We can also just add a single dummy image to the template and at runtime point to the correct image file either on the file system or via a URL. We can build the file location of the image quite easily using the XSL concat() function.  Note at runtime the incoming image will be resized (if necessary) to fit the same dimensions as the dummy image.
So in the Web tab of the image properties we have:

DynImg2:

File System: url:{concat(../IMG_DIR_PATH,'/',IMGFILE)} See DynamicImg3.rtf
URL: url:{concat(../IMG_SERVER,'/',../IMG_DIR,'/',IMGFILE)} See DynamicImg4.rtf


Notice we use '../' to get a level up from the G_VENDOR_NAME level for the root level values we need to construct the path or URL i.e. ../IMG_DIR_PATH.


If you are an E Business Suite user you can also make use of the OA_MEDIA directory. XML Publisher will resolve this value at runtime. So for an image in the OA_MEDIA directory you could use:


url:{?${OA_MEDIA}/IMGFILE?}


You can get all the examples and XML data here.
So thats dynamic images, of course you can use it for any image and you can build much more complex conditional formatting rules around the images. Have a good day ...

Join the discussion

Comments ( 22 )
  • Tim Dexter Thursday, December 7, 2006
    Hi Justin
    Check the user guide it covers how to use parameters to pass a URL reference of an image to a template.
    Regards, Tim
  • Greg Partenach Tuesday, November 20, 2007
    Very useful tip here Tim, and I suspect we'll be using a combination of all of them here at some point. Thanks!
  • abhishek paliwal Friday, August 22, 2008
    Hi all,
    I want to use OA_MEDIA directory. In my xml i have a tag IMAGE which will give the image name available in OA_MEDIA directory.
    and in rtf i am inserting a dummy image. And writing the following syntex in web section:
    url:('${OA_MEDIA}','/',IMAGE)
    But now also i am not getting image in the PDF Output.
    But if i give complete path in my xml file under IMAGE tag and in rtf i write url:(IMAGE) i am getting images.
    Please can anybody help me in this case.
    It would be better if provide me one sample rdf and rtf with OA_MEDIA directory example.
    Thanks
    Abhishek paliwal
  • Tim Friday, August 22, 2008
    Abhishek
    This is better asked on the Publisher forum on OTN
  • Tommy Tuesday, March 31, 2009
    Hi,
    I want to include a .svg-picture from a xml-source, the xml tag is:

    <Q14_ADRESSE>
    http://server/picture.svg?par_1=51859&par2=&par3=1&par4=1&par5=407749
    </Q14_ADRESSE>

    so I have many different pictures generated from another programm and I have only this tag.
    I woud prefer to do this with MSword, so I need a funktion. Another problem is, that MSword can't do .svg ... so I'm in trouble
    can someone help me?
    thanks
  • Guney Thursday, May 7, 2009
    Hi all,
    Before I start, many thanks for your deserving tutorial about dynamic image.
    I am very new on Xml Publisher and for a week, I have tried adding dynamic image in my reports. According to your statement
    that means Reference the images via a URL.
    I have created a XML element and put my image location in that tags, after that I've created an dummy image in my rtf file and changed this web alternative text properties according to format you mention above and also I have give full path in only one xml element but unfortunately the image doesnt appear im my output file.But when I ve used first method "Embedding image in the template", the image appears.
    Also I ve tried your examples data but the image again doesnt appears if I used Reference the images via a URL technique.
    Can you or anyone help me ?
    thank
  • Charandeep Hora Wednesday, January 13, 2010
    Hi,
    The article is great but i just had to sturggle in MS Word 2007 to find the format picture/Alignment text.
    Here is the navigation for MS-Word 2007
    On The Insert Tab Click on Picture Insert any dummy picture
    Right Click on the picture and select Size (NOT Format Picture). Select Alt Text and enter the info as mentioned in the Format Picture Dialog above in the blog
    Thanks
    Charandeep Hora
  • Brent Friday, January 29, 2010
    Tim
    I was wondering if there are any special tags that have to be defined in the XSD file to make the dynamic images work correctly. I have a set up much like yours however, when I attempt to pull in a different image I only get the the first image in the program no matter how I define the location and picture name.
    Also, the header on your report changes based on the ORG that is entered however you never appear to tell it to be part of the for loops. How is this being accomplished?
  • Tim dexter Friday, January 29, 2010
    Hi Brent
    Can you mail me the data and data?
    Tim
  • Sajith Wednesday, February 17, 2010
    Hi All,
    Is there a way to specify the size of the image dynamically? To explain in detail, suppose I have an image to be placed in my report and it is a dynamic one. I use "url:{ROOT\IMAGE}" command in the web tab of the image properties to use the url I pass in the XML file to render the image.
    Now, let's say the dummy image I placed on the rtf template is of size 50X50 and the actual image that is coming from the URL is of size 100X150. The image gets distorted.
    Is there a way to pass the height and width in the XML along with the image url? I am looking for a way to specify my xml in such a way that
    http://mysystem/image.jpg100150

    and use these parameters in the rtf template so that my image rendered from the url is displayed in its actual size i.e. 100X150 rather than the dummy image's size 50X50 which would look distorted.
    Thanks in advance for your help!
    Sajith
  • Beena Wednesday, March 24, 2010
    I am using WORD 2007 with BI Publisher and trying to create a chart in the RTF document. I added a dummy image using Insert Picture -> Link to File, Right click on the picture and select size and then alt text to add the code for the chart but I only get the picture in the image. I have a very simple XML data file for this.
    I am also trying to use the CHART object Bi Publisher in word but the Preview and Ok button are always disabled. I am using the same XML dat file. Any ideas?
    Thanks for any help.
    Beena
  • Siva Kumar Tuesday, June 29, 2010
    Thank you so much for giving these many options. It really worked for me.
  • tomas Friday, August 6, 2010
    information at its best
  • kl&auml;der Wednesday, August 18, 2010
    Thanks for this post
  • missoula dentist Wednesday, September 22, 2010
    What's up with your header masking the navigation menu? Shouldn't it be towards the top?
  • Barbara Bach Saturday, September 25, 2010
    There'll invariably be someone doing some thing exclusively for the surprise worth of it. Gal Gaga claims she would not want to affront vegetarians and that she wasn’t a joint of beef.....in fact what was the woman's idea?....what will we have now experienced with the assertion this girl was trying to make? I will explain to you..zero. All many of us do not forget is the "meat" dress costume. Ask yourself how long the lady stays up nights thinking up tricks to keep us discussing her.
  • archana Wednesday, March 7, 2012

    Hi Tim,

    I'm very new to XML. Your tutorial gave me a fair idea on how to implement dynamic images. But unfortunately, I'm not able to access the example files at http://blogs.oracle.com/leslieStuddard/resource/gems/DynImages.zip Could you please mail me a sample RTF.

    Thanks and Regards,

    Archana


  • Lenin Thursday, April 19, 2012

    HI Tim,

    Thanks for your detailed info, I am not able to download the sample files form the above. could you please send the zip files to my email mleninbabu@gmail.com

    Thanks,

    Lenin


  • Tim Friday, April 20, 2012

    I have updated the link, should be OK now

    https://blogs.oracle.com/xmlpublisher/resource/files/DynImages.zip

    Tim


  • Tim Tuesday, March 5, 2013

    Hi Richard

    Sorry, but I do not have access to Word 2010 so I can not test. 2010 is a supported app so please log an SR with Oracel support for some help

    Tim


  • Rajeswari Tuesday, August 5, 2014

    Hi,

    Will there be any dimensions for a Image ,which we going to insert in a oracle report?

    I am trying to insert a jpg file in a Report

    and I am getting

    "Rep-0606 unable to read file '<path>' check the link file format"

    Any suggestions on this please....

    Thanks.,


  • suboh Thursday, August 27, 2015

    Hi , I have created a report definitions imbedded to BI Publisher RTF format contains url for an image in ALT Text tape over the JDE application , and when I generate the report to excel format the image appeared , but when generate to PDF formate it will not appear!!!! ,however when I preview the rtf formate to PDF the image in local machine appeared , The issue just is when generate to PDF on the enterprise server ?????? PLEASE HOW I CAN SOLVE IT


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.