Working with Images
The process of adding an image to a layout consist of two main steps. The first step involves the Report Designer layout tool, in which you must add a reference to the image by adding an image object to the layout and specifying the required image settings. The second step involves including runtime support for the image. This page describes different scenarios related to working with images.
When adding runtime support for the image one can either have the image stored on a disk or it can also be stored in a database and have it fetched in runtime. Both these scenarios are described in detail below.
Working with images stored on disk
In this approach the image to be fetched in runtime is stored on a disk. This could be either on the application server or on a different machine. Following are some common scenarios of working with images where the image is stored and fetched from disk in runtime.
How to add an IFS company logo
The steps below describe the process of adding a IFS logo (IFSlogbw.gif) to your report. This includes adding an image reference to the layout in design time and storing the image on disk for runtime support.
- Set the default graphics path in the Report Designer tool - Go to IFS Report Designer Options dialog (Edit menu Options ) and specify the Graphics path as shown below:
This is generally a file location in your client machine and needs to be done only once since it is a tool setting.
- Add the image to the schema tree - Go to the Graphics folder listed under the schema tree and select Add graphics from the RMB menu options.
- Browse to the image you want to use.
Press Ok to continue. The selected image file will now be listed under the schema tree as depicted below. Once the image is added a folder structure containing this image will be created under the graphics path specified in step (1). This structure comprises of the following elements. report_designer_graphics\<module_name>\<package_name>\IFSlogbw.gif.
Now place the image on the layout by simply dragging and dropping the image from the schema tree to the layout. It's important to remember in this step that it is only a reference to the image that is added to the layout and the actual image does not get embedded to the layout. The reference to the image is usually a file path or a http/ftp path which will be used in runtime to fetch the image from it's stored location.
When you drag and drop the image on the layout, the image property "Keep aspect ratio" will be selected.
If the property is checked the image will shrink until it completely fits inside the container box/table cell width. The aspect ratio (proportions) of the image will stay as the original. The alignment inside the box will be upper left corner. If the checkbox is unchecked, the image will align to the upper left corner, but the image will be resized according to the parent (Container) dimensions. Following image shows the sample preview of different instances, when the property enabled and disabled. For table cell this option is always on.
6. To get the default logotype behavior simply select the Dynamic image stored on disk option and check the default logotype support check box. The default behavior will work as follows.
1. If an archive variable with the name `rhSysLogo` exists for this particular archive item that logotype will be used. 2. If no `rhSysLogo` archive variable exists the logotype specified in the **default logotype**XML element will be used. This logotype is either the <dfn>complogo.gif</dfn> if such file exist or the <dfn>ifslogbw.gif</dfn> if no <dfn>complogo.gif</dfn> exist. Both these files should be located in the <dfn>stdlogo</dfn> sub folder in the specified Report Designer graphics root folder. 3. Any logotype path specified in <dfn>rhSysLogo</dfn> archive variable will be overridden by changing the file extension from.bmp to.gif. This is necessary since IFS Report Designer doesn't work with bitmap images. Any bitmap logotype used needs to be converted to gif, jpeg, or png images to be able to be used with Report Designer.
- Save and preview the layout from the tool and verify if the image is correctly shown in design time.
How to add a non-IFS company logo
- Set the default graphics path in the Report Designer tool if it's not done already.
- In order to view this company logo from the tool's preview you must have the corresponding image file in your client machine. Name this image file as complogo.gif.
- Add a reference to the image file in your layout by following steps from (2) to (4) above.
- Select Dynamic image stored on disk option and make sure the Default logo support check box has been selected.
- Execute the report and verify that the company logo can be previewed in runtime.
If complogo.gif file does not exist the IFS logo will be shown as the default company logo.
How to add non logo type images
Sometimes you may need to add a static image that does not necessarily serve as a company logo rather servers a different purpose in the report functionality. If your requirement is such then follow the instructions below to get the images working for your report.
Perform the steps from (1) to (4) listed in the first scenario and add an image object to the layout. This will create the following folder structure inside the tool's default graphics path. See step (1).
Select the option Dynamic image stored on disk and clear the following items:
- Checkbox for default logotype support (Uncheck)
- Value set for Explicit runtime image path
- Value set for Fallback runtime image path
Set the File extension conversion value to that of your image file (gif, png or jpeg)
For runtime support the same folder structure should be checked in to the version control system.
One can also use a http/ftp path when referring to images. The http/ftp path in this case must point to the image file of your choice.
- Add an image object to the layout.
- In the Explicit runtime image path specify the http/ftp path containing the image file of your choice.
- Save the layout execute the report and verify if the image can be seen in runtime.
Working with images stored in database
In this approach the images to be referenced in the report must be stored in the database. When a request is made to print or preview the report the image/images are directly fetched from the database table. The relevant image is returned using a SQL statement that is specified in the layout. This query is set using the Report Designer Tool as shown below.
Follow the steps below to add design time support and runtime references.
- Add an image object to the layout.
- Select the option Dynamic image stored in Database.
- In the text field SQL statement returning an image, specify a valid SQL query which will return the desired image from the database table.(SELECT data FROM binary_data_block WHERE blob_id=:1 AND seq=:2) The values given for the WHERE clause can be passed on as Binding variables. For instance in the above example, the value for blob_id is mapped to the first bind variable (tns:PICTURE_ID) which is denoted by "=:1" and the value for seq will be mapped to the second bind variable(1) which is denoted by "=:2". Up to five bind variables can be specified in the field Bind variable values each separated by semicolons. The value given for a Bind variable can be a Xpath such as tns:PICTURE_ID returning a valid id or even a hardcoded value such as the second bind variable in the example above. When the report is executed in runtime the above sql query information you provide is used to retrieve the correct image from the database table.
However when the report is previewed from the Report Designer Tool, the images are fetched from the client machine where the tool is running and not from the database. Similar to how it works in the all of the previous scenarios listed above.
To complete the runtime setup make sure the images have been saved on to the database. Use BLOB or LONG RAW formats for storing.
Working with dynamic images
Dynamic images are those in which the image changes depending on some variable in the XML or based on some condition. Dynamic images can be added to a report using both approaches described above. That is the images can either reside on a disk or be stored in a database. For example when you use a XPath to fetch images stored from a database as shown above is a typical example of using dynamic images.
Following scenarios describe how to work with dynamic images when the images are stored on disk. First a reference to the image must be given in the layout. This is done by adding some image object to the layout and specifying the means in which the image path is fetched in runtime. The next step is where the image files are copied to the application server.
Fetch the runtime image path using a XPath value
The file paths to the dynamic image can be fetched using a value returned from a XPath. This is very similar to how we fetch all other data items from the XML. The difference being that in the XML a file path is stored for the corresponding XPath and not the actual data (the image in our case) embedded to the XML.
Follow the steps below to add dynamic images using a XPath reference.
Add an image object to the layout.
Set the XPath (which will return a file path to the image) in the Explicit runtime image path.
In the above example the XPath tns:INVENTORY_PART_IMAGE should return a valid file path. For example C:\temp\part1.gif. It is also possible to pass a http/ftp path for the XPath value.
In the application server, make sure the image files are physically present in the folder path returned by the XPath value. If not, copy the image files to the corresponding location in the application server. In the case of a http/ftp path being returned by the XPath value you need not copy any image files to the application server.
Execute the report and verify if the image can be seen in runtime.
Use of rhSysLogo
The rhSysLogo variable specified in the RDF can also be used specify different image paths depending on different report conditions. For instance one can set different image paths to the rhSysLogo variable depending on different company id's. This way you can display the different company logo's on the same report when the company id changes.
- Add an image object to the layout.
- Make sure the Default logo support checkbox has been selected.
- Execute the report and verify if the image can be seen in runtime.