I have a Crystal Report with a class as a data source. I have a byte array which I am passing a bitmap to but it isn't printing on the Crystal Report. Please see my code below.
var d = new Label();
var eanCreator = new CreateEan();
var bf = new BinaryFormatter();
using (var ms = new MemoryStream())
{
bf.Serialize(ms, eanCreator.createBitmap(1.5f, "1234567890"));
var byteArray = ms.ToArray();
var ld = new LabelData
{
PartNumber = "123",
EanData = byteArray
};
d.SetDataSource(new List<LabelData> {ld});
d.PrintOptions.PrinterName = @"\\SERVER\Printer";
d.PrintToPrinter(1, false, 0, 0);
}
The print comes out, all data except the image is present. I am using a class to create an EAN barcode, this part renders correctly to an image file, but just won't recognise it within Crystal Reports.
To be able to show the image on the report, when you pull the image Field of your DataSet, it has to be IBlobFieldObject in CR. I had a lot of trouble achieving this. Eventually i removed the DataSet from the report (through 'Database expert') and re-added it. Also make sure, that your Image field is set to byte[] in the DataSet.
This method is similar to your code. I use this method all the time to send an image to Crystal Reports without problems.