Crystal Report image from byte array not printing(来自字节数组的水晶报表图像不打印)
问题描述
我有一个带有类作为数据源的 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;
}
这篇关于来自字节数组的水晶报表图像不打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:来自字节数组的水晶报表图像不打印
基础教程推荐
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
