问题描述
我有一个带有类作为数据源的 Crystal Report.我有一个字节数组,我将位图传递给它,但它没有在 Crystal Report 上打印.请在下面查看我的代码.
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 = @"\SERVERPrinter";
d.PrintToPrinter(1, false, 0, 0);
}
打印出来了,除了图像之外的所有数据都存在.我正在使用一个类来创建 EAN 条码,这部分可以正确呈现为图像文件,但在 Crystal Reports 中无法识别.
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.
推荐答案
这个方法和你的代码类似.我一直使用这种方法将图像发送到 Crystal Reports 没有问题.
This method is similar to your code. I use this method all the time to send an image to Crystal Reports without problems.
public static byte[] ConvertImageToByte(Image Value)
{
if (Value != null)
{
MemoryStream fs = new MemoryStream();
((Bitmap)Value).Save(fs, ImageFormat.Jpeg);
byte[] retval= fs.ToArray();
fs.Dispose();
return retval;
}
return null;
}
这篇关于来自字节数组的水晶报表图像不打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)