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

Dynamic loading of an image into a report


I am using VS.Net 2003 and the version of Crystal Reports that is bundled with it.

Is it possible set the content of an object of the report to an image (from a C1Chart object).

For text objects, we can do this :
 CType(ReportToPrint.ReportDefinition.ReportObjects(vstrTextObject), CrystalDecisions.CrystalReports.Engine.TextObject).Text = vstrTextValue

Is there any way of doing something like this for images?
Éric Moreau
Éric Moreau
  • 3
1 Solution
WHat type is the image?  Crystal is limited in the image types it handles.

Can you save the chart as a bmp or jpg?

Éric MoreauSenior .Net ConsultantAuthor Commented:
I bind my reports to schema (.xsd) and I use SetDataSource to pass a dataset to the report. I seems that I cannot have an image as part of my schema.

>>Can you save the chart as a bmp or jpg?

I can save the image to all the formats supported by System.Drawing.Imaging.ImageFormat (bmp and jpg are part of the list).
Éric MoreauSenior .Net ConsultantAuthor Commented:
I found something really interesting (at least I find it personally very interesting).

This is how I did it:
-I have added a field of type base64Binary to my schema.
-I was then able to add this new field to my report (it appears as a IBlobFieldObject).
-Then in my code, I can convert the image of my chart directly to a DataRow of my datatable without saving it this way:
                Dim arrBytes() As Byte
                chtSectors.SaveImage(arrBytes, System.Drawing.Imaging.ImageFormat.Jpeg)
                dtChart.Rows.Add(New Object() {"SECTOR", "Sector Analysis", arrBytes})

Éric MoreauSenior .Net ConsultantAuthor Commented:
any objections in sending this questions to PAQ?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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