Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Business Objects: Crystal Reports 1 Formulas FAQ

Formula Help

Dynamic Images in a Crystal Report by chelseatech
Posted: 21 May 03 (Edited 26 Apr 06)

Extract From Crystal Clear 34 (March 2003)
Available from www.chelseatech.co.nz/pubs.htm
Updated April 2006

We usually have text and numeric data displayed in our reports.  Sometimes our database has image data and we might like to include this in our report as well.  There are several approaches to displaying a data driven image in your report.

The first is to make sure the image is of a sufficient size and quality.  There is no point in trying to take a large high quality image and try to display it as a thumbnail on your report.  Use one of the image editing programs to create an image you can display this at an adequate resolution and size.  

The format of the image is also important.  While a BMP is a fairly universal format, it can require a large space.  So it might be desirable to convert the image to a compressed format like JPG or PNG.  Crystal supports all these and several other formats.

The next question to answer is how to get the image into your report.  In the past we thought the only answer was to use the Database approach, but weÆve recently discovered several other approaches.

Database solution: Easy but requires significant disk space
You can store image data in fields in your database.  MS access calls these OLE fields while Oracle and SQL Server refers to them as BLOB (Binary Large Object) fields.  An example of this technique is the Xtreme sample database supplied with Crystal Reports.  In the Employee table is a field containing the photo of each employee.    You just place these fields on your report in a similar way to other fields.

On the positive side, you can directly relate an image field to database values.  On the negative side, these images can take up considerable space inside your database.  They can also have an adverse effect on performance and storage.

Developer Solution: Restricted functionality and requires a developer
In some Crystal Reports books, we have read about how you can write a Crystal Report viewer in a language such as Visual Basic. Inside your program you can trap such events as the formatting of a section, and you could then change the OLE objects in your report to load a different image.  

On the positive side, this lets you loosely couple your data and images.  On the negative side it requires a complex application to be developed and it will only work with specific reports. We were considering developing such a viewer until we came upon the next two techniques.  

We also heard recently that the section format event is not available to CR9 and later, and that event does not occur when you export the report.

Driver Solution:  Fast and flexible 3rd party product.
One of the great features in Crystal Reports 8.5 and later is that you can use a COM data source.  This means you can create a recordset from within some application code and then use it as the source of data for your report.  We have developed cViewIMAGE, a com data source that asks for a filename and builds a recordset with an embeded image.

Use this in a subreport to display that filename as an image in your report. Additional options include a wild card of all the images in a folder, and you can retrieve an image from a web server.

Version 4.0 includes the height and width of the image, so you can use this with conditional formating to display the imaage correctly

Delivery Solution: Simple and inexpensive to install a UFL
The fourth solution is to Export to HTML using our SMTP UserFunction Library .  We have User Function Libraries that send output to Outlook, XML or a disk file.  Some call this ôReport Burstingö where your report engine uses function libraries to generate multiple output files.

We have an SMTP library that can embed images in an HTML message as the report is processing.  It is a standard function in our SMTP library

Dynamic Images in Crystal Reports XI
Crystal Reports XI includes dynamic images as one of it's key features.  In addition it can retrieve images from a web server (although these can't be displayed using the current version of Crystal Enterprise)

These images have a problem if they are of different sizes, as they must all appear with the same size and shape.

New information about missing images (April 2006)
With Crystal Reports XI, you insert an image in the report, and then use conditional formatting to select an image from a file.  If it can't find a file, then the original image remains unchanged.

With cViewIMAGE, if the image can't be found, a NULL or empty images appears.

Back to Business Objects: Crystal Reports 1 Formulas FAQ Index
Back to Business Objects: Crystal Reports 1 Formulas Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close