Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 219
  • Last Modified:

How to insert an Image into report when only the image's filename and path is known at runtime?

I need to insert an image in a report (Crystal v8.5), but the image file isn't known until runtime.

The record being reported on contains a field with the filename and path.

For example, the record has a field containing a string "C:\images\Photo of Mark.jpg." That's the file I want to display on the report.

The image file is external to the database. Only the filename and path is stored in the database.

  • 2
1 Solution
If this is within an application, then here's an example of how to read an image from a path at runtime:

If this is within the Crystal designer,  Chelsea Technologies has a plug-in (cViewIMAGE - it's actually a COM data source that is used in a subreport) that does this.  You can download a trial version here: http://www.chelseatech.net/download.htm

I don't know of any other way.  They finally added this functionality to CR XI.  If you want to take it for a test drive, you can get it here:

If report is within your application

Add any image in crystal report and change the value at runtime through follwing code in Section_Format event

Following is samle code is provided for VB6/CR 8.5

Private Sub Section14_Format(ByVal pFormattingInfo As Object)
    Set picPhoto.FormattedPicture = LoadPicture(fldPhoto.Value)
End Sub
miocolanoAuthor Commented:
Thanks to both of you.
I am awarding the points to Dave because he answered first and provided three solutions and because the example he provided included the technique described by stcindia.  
I think that although I will be calling the report from a program, I may use cViewImage instead because it looks simpler. Also, the directions for the LoadPicture() function don't  mention JPG images, only Bitmaps and one or two other formats.
I'll need time to work these out, but I suspect that at least one of these approaches should work for me.
Thanks again,
Glad to help.


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now