CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  ASP.NET

WEB页面如何打印条形码

楼主xwqhml()2005-07-22 11:50:24 在 .NET技术 / ASP.NET 提问

能找些例子也好  
  初步想用.net自带的BarCodeCtrl  
   
  先谢了!! 问题点数:100、回复次数:15Top

1 楼WeekZero(∮小气的鬼∮)回复于 2005-07-22 11:59:59 得分 80

public   string   bar_code(object   str,   int   ch,   int   cw,   int   type_code)  
  {  
  string   strTmp=str.ToString();  
  string   code=strTmp;  
  strTmp=strTmp.ToLower();  
  int   height=ch;  
  int   width=cw;  
   
  strTmp=strTmp.Replace("0",   "_|_|__||_||_|");;  
  strTmp=strTmp.Replace("1",   "_||_|__|_|_||");  
  strTmp=strTmp.Replace("2",   "_|_||__|_|_||");  
  strTmp=strTmp.Replace("3",   "_||_||__|_|_|");  
  strTmp=strTmp.Replace("4",   "_|_|__||_|_||");  
  strTmp=strTmp.Replace("5",   "_||_|__||_|_|");  
  strTmp=strTmp.Replace("7",   "_|_|__|_||_||");  
  strTmp=strTmp.Replace("6",   "_|_||__||_|_|");  
  strTmp=strTmp.Replace("8",   "_||_|__|_||_|");  
  strTmp=strTmp.Replace("9",   "_|_||__|_||_|");  
  strTmp=strTmp.Replace("a",   "_||_|_|__|_||");  
  strTmp=strTmp.Replace("b",   "_|_||_|__|_||");  
  strTmp=strTmp.Replace("c",   "_||_||_|__|_|");  
  strTmp=strTmp.Replace("d",   "_|_|_||__|_||");  
  strTmp=strTmp.Replace("e",   "_||_|_||__|_|");  
  strTmp=strTmp.Replace("f",   "_|_||_||__|_|");  
  strTmp=strTmp.Replace("g",   "_|_|_|__||_||");  
  strTmp=strTmp.Replace("h",   "_||_|_|__||_|");  
  strTmp=strTmp.Replace("i",   "_|_||_|__||_|");  
  strTmp=strTmp.Replace("j",   "_|_|_||__||_|");  
  strTmp=strTmp.Replace("k",   "_||_|_|_|__||");  
  strTmp=strTmp.Replace("l",   "_|_||_|_|__||");  
  strTmp=strTmp.Replace("m",   "_||_||_|_|__|");  
  strTmp=strTmp.Replace("n",   "_|_|_||_|__||");  
  strTmp=strTmp.Replace("o",   "_||_|_||_|__|");  
  strTmp=strTmp.Replace("p",   "_|_||_||_|__|");  
  strTmp=strTmp.Replace("r",   "_||_|_|_||__|");  
  strTmp=strTmp.Replace("q",   "_|_|_|_||__||");  
  strTmp=strTmp.Replace("s",   "_|_||_|_||__|");  
  strTmp=strTmp.Replace("t",   "_|_|_||_||__|");  
  strTmp=strTmp.Replace("u",   "_||__|_|_|_||");  
  strTmp=strTmp.Replace("v",   "_|__||_|_|_||");  
  strTmp=strTmp.Replace("w",   "_||__||_|_|_|");  
  strTmp=strTmp.Replace("x",   "_|__|_||_|_||");  
  strTmp=strTmp.Replace("y",   "_||__|_||_|_|");  
  strTmp=strTmp.Replace("z",   "_|__||_||_|_|");  
  strTmp=strTmp.Replace("-",   "_|__|_|_||_||");  
  strTmp=strTmp.Replace("*",   "_|__|_||_||_|");  
  strTmp=strTmp.Replace("/",   "_|__|__|_|__|");  
  strTmp=strTmp.Replace("%",   "_|_|__|__|__|");  
  strTmp=strTmp.Replace("+",   "_|__|_|__|__|");  
  strTmp=strTmp.Replace(".",   "_||__|_|_||_|");  
  strTmp=strTmp.Replace("_",   "<span   style='height:"+height+";width:"+width+";background:#FFFFFF;'></span>");  
  strTmp=strTmp.Replace("|",   "<span   style='height:"+height+";width:"+width+";background:#000000;'></span>");  
   
  if(type_code==1)  
  {  
  return   strTmp+"<BR>"+code;  
  }  
  else  
  {  
  return   strTmp;  
  }  
  }  
   
  这个函数的调用:Label1.Text=bar_code(str,52,2,1);  
   
  打印时在浏览器的“工具”中“高级”,“打印”下的“打印背景颜色和图像”打上钩就可以了。Top

2 楼brando_beat(Eの懒龙)回复于 2005-07-22 12:19:20 得分 0

帮你UpTop

3 楼mapserver(杨东 http://mapserver.cnblogs.com)回复于 2005-07-22 12:22:56 得分 3

WeekZero(星期零)的方法可行。Top

4 楼chenyun_424(求教的人)回复于 2005-07-22 12:45:13 得分 0

哇,顶!~Top

5 楼windydenny(布丁貓貓)回复于 2005-07-22 16:15:01 得分 8

Dim   strFontName   As   String   =   "C39HrP48DhTt"  
  Dim   intFontSize   As   Integer   =   70  
  Dim   strShowName   As   String   =   lblrma.Text.Trim  
  Dim   objBitmap   As   Bitmap  
  Dim   g   As   Graphics  
  Dim   stringFont   As   Font   =   New   Font(strFontName,   intFontSize,   FontStyle.Regular)  
  Dim   stringFormat   As   StringFormat   =   New   StringFormat  
  stringFormat.FormatFlags   =   StringFormatFlags.NoWrap  
  Try  
        Dim   filename   As   String   =   "barcode.jpg"          
        objBitmap   =   New   Bitmap(1,   1)  
        g   =   Graphics.FromImage(objBitmap)  
        Dim   stringSize   As   SizeF   =   g.MeasureString(strShowName,   stringFont)  
        Dim   nWidth   As   Integer   =   CType(stringSize.Width,   Integer)  
        Dim   nHeight   As   Integer   =   CType(stringSize.Height,   Integer)  
        g.Dispose()  
        objBitmap.Dispose()  
   
        objBitmap   =   New   Bitmap(nWidth,   nHeight)  
        g   =   Graphics.FromImage(objBitmap)  
        g.FillRectangle(New   SolidBrush(Color.White),   New   Rectangle(0,   0,   nWidth,   nHeight))  
        g.DrawString(strShowName,   stringFont,   New   SolidBrush(Color.Black),   New   PointF(0,   0),     stringFormat)  
        objBitmap.Save(Server.MapPath(".")   &   filename,   Imaging.ImageFormat.Jpeg)       '----圖片的生成路徑  
   
  Catch   ex   As   Exception  
        Response.Write(ex.Message)  
  Finally  
        g.Dispose()  
        objBitmap.Dispose()  
  End   TryTop

6 楼xwqhml()回复于 2005-07-25 11:30:54 得分 0

to:   WeekZero(星期零)    
   
  感觉结果有点不可思议,十几位字符条码好长  
   
  还有个问题,这样做出来的条码枪能识别吗?Top

7 楼ligaru(为了生活重新学C++)回复于 2005-07-25 11:35:35 得分 0

等结果Top

8 楼codeangel(http://www.wSoft.Net)回复于 2005-07-25 11:42:27 得分 3

调整这个行吗?   int   ch,   int   cwTop

9 楼designonline(meetweb)回复于 2005-07-25 12:03:59 得分 3

建议使用代码生成图片.然后保存到sqlserve里,然后在水晶报表或者代码里输出Top

10 楼brando_beat(Eの懒龙)回复于 2005-07-25 12:15:35 得分 3

还有就是你上面的条码是什么码阿,39码还是128码,这样的程序我没有看到有什么地方设置阿??  
  我application做过,但是,Web上面我没有做过。Top

11 楼acco(天天)回复于 2005-07-25 13:33:46 得分 0

upTop

12 楼evafly920(伊凡网络)回复于 2005-07-25 13:36:25 得分 0

帮你顶  
   
  -----------------------------------------------------  
  网站改版,全部用.NET重写,大家批批^_^  
  好不好给个意见,非常感谢  
  记得发邮件给我哦cn5135@163.com  
   
  http://www.cn5135.comTop

13 楼xlfrd(显亮.net)回复于 2005-07-25 13:50:03 得分 0

用GDI+画行不行Top

14 楼jimu8130(火箭的未来在哪里?)回复于 2005-07-25 13:56:35 得分 0

学习Top

15 楼wendy_fw(文子)回复于 2005-09-24 09:45:35 得分 0

掃描槍掃不到啊!  
  為什麼啊?Top

相关问题

  • 有无可在Web页面中使用和打印的条形码控件?谢谢!
  • 有无可在Web页面中使用和打印的条形码控件?谢谢!
  • 怎样实现asp.net页面中打印条形码?
  • 怎样实现asp页面中打印条形码?
  • 条形码打印?
  • 条形码打印
  • 条形码打印
  • 条形码打印
  • 有条形码的打印软件吗?
  • 觅条形码打印控件!

关键词

  • .net
  • 打印
  • code
  • strtmp
  • replace
  • objbitmap
  • stringsize
  • dim
  • integer
  • str

得分解答快速导航

  • 帖主:xwqhml
  • WeekZero
  • mapserver
  • windydenny
  • codeangel
  • designonline
  • brando_beat

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo