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

Crystal reports not showing blob images from dataset

Hello all,

I have a dynamically generated dataset with a tiff image base64 encoded in it.  I put the blob image into a reportdocument and it doesn't show up when I run the report.  I know the image is good because I can covert from base 64 then export to disk and the image will be there fine on the disk.  The app is in ASP.NET 2.0, CR 11 Developer.

XSD file looks like:
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="Table1">
        <xs:element name="Image1" type="xs:base64Binary" minOccurs="0" />
  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="true">
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="Table1" />

The code that loads the report looks like:

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim dsCustoms As DataSet = CType(Session("sesCustoms"), DataSet)
Dim crCustoms As New CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim Mstream As New MemoryStream
Mstream = CType(crCustoms.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat), MemoryStream)
Response.Buffer = True
Response.ContentType = "application/pdf"
End Sub

The report is fairly plain.  I put the blob image in the detail area and make sure that "Can Grow" is checked.

So, what am i doing wrong?  What's going on?  How do I fix it?

1 Solution
This is just a guess, but possibly Crystal can't handle the image format?  I would try putting a .bmp image and see if that works.  At least that will isolate whether the problem is the image or something else.
Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
I believe frodoman is right.  Crystal only displays .jpg and .bmp images (.gifs if you view the report in a DHTML browser, but there are limitations).

jfoutzAuthor Commented:
Well, the docs say that a tiff is an acceptable format, but it's not like it would be the first they were flat out wrong...  So, I was hoping you were right and did the conversion:

Dim x As MemoryStream = New MemoryStream(Convert.FromBase64String(dsResponse.Tables(0).Rows(0).Item(0).ToString()))
Dim y As System.Drawing.Image = System.Drawing.Image.FromStream(x)
Dim z As New MemoryStream
y.Save(z, System.Drawing.Imaging.ImageFormat.Bmp)
dsResponse.Tables(0).Rows(0).Item(0) = Convert.ToBase64String(z.ToArray)

I know the conversion worked because I can output it to disk and the image is there intact.  i.e.
My.Computer.FileSystem.WriteAllBytes("c:\tmp1\tmp1.bmp", z.ToArray(), False)

But...  still no image in my report.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

jfoutzAuthor Commented:

Is there any other way to get images into a report without resorting to temp files?  As I understand, a dataset is the only way.
With CR11 you are supposed to be able to put the image file name in the field and Crystal will pull up the image.

Are you running a local application or is this a server application.  The image must be in the correct directory which may be the server or the client depending on how the application is run.

jfoutzAuthor Commented:
So I finally broke down and opened a case with Business Objects.

The problem turned out to be encoding…  Specifically, I was forwarding a base 64 string of the binary to Crystal, while Crystal will only accept a non-encoded byte array of the binary.  Of course the schema still had to specify that the field was a “xs:base64Binary” even though the data couldn’t be forwarded with base 64 encoding.  The other methods of sending data to Crystal such as an XML file can send a base 64 string no problem.  

I requested that Business Objects consider either allowing a dataset to send blob images as base 64 strings (since that’s how they generally exist in databases anyways) in future builds, or specify in the documentation that a dataset can only pass a blob image on as a non-encoded byte array.

Thank you to everyone who looked at this problem.
Closed, 500 points refunded.
The Experts Exchange
Community Support Moderator of all Ages

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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