社区
C#
帖子详情
RDLC如何打印若干个内存中的图片
CSharpEx
2009-06-10 11:54:05
RDLC如何打印若干个内存中的图片
图片很多,不允许在本地硬盘缓存
...全文
111
12
打赏
收藏
RDLC如何打印若干个内存中的图片
RDLC如何打印若干个内存中的图片 图片很多,不允许在本地硬盘缓存
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
12 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
CSharpEx
2009-06-17
打赏
举报
回复
没有什么满意的结果
CSharpEx
2009-06-15
打赏
举报
回复
寻求解决办法
cnming
2009-06-15
打赏
举报
回复
要不使用PrintDocument
CSharpEx
2009-06-13
打赏
举报
回复
up
周药师
2009-06-11
打赏
举报
回复
帮顶
zlb789
2009-06-11
打赏
举报
回复
关注
yanm7788
2009-06-11
打赏
举报
回复
UP
cnming
2009-06-11
打赏
举报
回复
把图片存入一个DataSet中
cnming
2009-06-11
打赏
举报
回复
1.条码的生成:
private Bitmap GetCode39(string strSource)
{
int x = 5; //左邊界
int y = 0; //上邊界
int WidLength = 2; //粗BarCode長度
int NarrowLength = 1; //細BarCode長度
int BarCodeHeight = 24; //BarCode高度
int intSourceLength = strSource.Length;
string strEncode = "010010100"; //編碼字串 初值為 起始符號 *
string AlphaBet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%*"; //Code39的字母
string[] Code39 = //Code39的各字母對應碼
{
/**//* 0 */ "000110100",
/**//* 1 */ "100100001",
/**//* 2 */ "001100001",
/**//* 3 */ "101100000",
/**//* 4 */ "000110001",
/**//* 5 */ "100110000",
/**//* 6 */ "001110000",
/**//* 7 */ "000100101",
/**//* 8 */ "100100100",
/**//* 9 */ "001100100",
/**//* A */ "100001001",
/**//* B */ "001001001",
/**//* C */ "101001000",
/**//* D */ "000011001",
/**//* E */ "100011000",
/**//* F */ "001011000",
/**//* G */ "000001101",
/**//* H */ "100001100",
/**//* I */ "001001100",
/**//* J */ "000011100",
/**//* K */ "100000011",
/**//* L */ "001000011",
/**//* M */ "101000010",
/**//* N */ "000010011",
/**//* O */ "100010010",
/**//* P */ "001010010",
/**//* Q */ "000000111",
/**//* R */ "100000110",
/**//* S */ "001000110",
/**//* T */ "000010110",
/**//* U */ "110000001",
/**//* V */ "011000001",
/**//* W */ "111000000",
/**//* X */ "010010001",
/**//* Y */ "110010000",
/**//* Z */ "011010000",
/**//* - */ "010000101",
/**//* . */ "110000100",
/**//*' '*/ "011000100",
/**//* $ */ "010101000",
/**//* / */ "010100010",
/**//* + */ "010001010",
/**//* % */ "000101010",
/**//* * */ "010010100"
};
strSource = strSource.ToUpper();
//實作圖片
Bitmap objBitmap = new Bitmap(((WidLength * 3 + NarrowLength * 7) * (intSourceLength + 2)) + (x * 2), BarCodeHeight + (y * 2));
Graphics objGraphics = Graphics.FromImage(objBitmap);
//宣告GDI+繪圖介面
//填上底色
objGraphics.FillRectangle(Brushes.White, 0, 0, objBitmap.Width, objBitmap.Height);
for (int i = 0; i < intSourceLength; i++)
{
//檢查是否有非法字元
if (AlphaBet.IndexOf(strSource[i]) == -1 || strSource[i] == '*')
{
objGraphics.DrawString("含有非法字元", SystemFonts.DefaultFont, Brushes.Red, x, y);
return objBitmap;
}
//查表編碼
strEncode = string.Format("{0}0{1}", strEncode, Code39[AlphaBet.IndexOf(strSource[i])]);
}
strEncode = string.Format("{0}0010010100", strEncode);
//補上結束符號 *
int intEncodeLength = strEncode.Length;
//編碼後長度
int intBarWidth;
for (int i = 0; i < intEncodeLength; i++)
//依碼畫出Code39 BarCode
{
intBarWidth = strEncode[i] == '1' ? WidLength : NarrowLength;
objGraphics.FillRectangle(i % 2 == 0 ? Brushes.Black : Brushes.White, x, y, intBarWidth, BarCodeHeight); x += intBarWidth;
}
return objBitmap;
}
2.生成条码图片
MemoryStream oStream2 = new MemoryStream();
try
{
Bitmap oBmp2 = GetCode39(goodsNum);
oBmp2.Save(oStream2, System.Drawing.Imaging.ImageFormat.Png);
//图片路径
oBmp2.Save(url + goodsName + ".png", System.Drawing.Imaging.ImageFormat.Png);
oBmp2.Dispose();
}
finally
{
oStream2.Dispose();
}
3.读取条码图片转化为二进制流
FileStream file = new FileStream(url + freightBill + ".png", FileMode.Open, FileAccess.Read);
Byte[] bytGoodsCode = new Byte[file.Length];
file.Read(bytGoodsCode, 0, bytGoodsCode.Length);
file.Close();
4.将条码图片保存进数据库
5.将条码图片在报表上显示出来:
在报表上拖放一个image图像控件,Source设置为DataBase(External为嵌入图片,Embedded为外部图片),Value 选择条码字段,设置MIMEType属性。
这样就能看见报表上面的图片了。
注:本来数据库存放条码图片的URL,但是在报表上用Embedded显示图片的时候,给image控件绑定了条码图片的URL值,但是运行图片显示不出,image控件的SRC="";还没有找到问题。
CSharpEx
2009-06-11
打赏
举报
回复
up
修改一下昵称
2009-06-11
打赏
举报
回复
帮顶 。up...ing
Rdlc
打印
一维码二维码
打印
c#winform写的
打印
, 含
Rdlc
报表,报表里面有一维码和二维码生成。供菜鸟学习。欢迎交流。
GRIDVIEW动态添加列及
RDLC
打印
GRIDVIEW动态添加列及
RDLC
打印
GRIDVIEW动态添加列及
RDLC
打印
GRIDVIEW动态添加列及
RDLC
打印
rdlc
报表的
打印
rdlc
报表的条码
打印
,内含
打印
对话框的调用
打印
按钮的api,
直接
打印
RDLC
报表
直接调用,传递参数即可 可在asp.net下或winform下使用,无需预览直接进行
打印
,可根据自己的需要进行修改 有适当的备注
RDLC
打印
二维码
C#简单易懂的
RDLC
(水晶报表)
打印
二维码,全CSDN最低积分
C#
110,535
社区成员
642,575
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章