ASP.NET 生成条形码
类别:编程学习 浏览量:934
时间:2013-8-16 ASP.NET 生成条形码
ASP.NET 生成条形码用ASP.NET生成条形码的思路:把条码里的字符一个个按照规定的对应表换为二进制串,然后0用#FFFFFF,1用#000000的颜色表示出来。代码如下:
/// <summary>
/// 条形码生成
/// </summary>
/// <param name="strTemp">要生成条形码的文本</param>
/// <param name="height">每个_和|的高度</param>
/// <param name="width">每个_和|的宽度</param>
/// <param name="showstrTemp">是否显示文本</param>
/// <example>Response.Write(CreateBarCode("6911989251236", 50, 1, true));</example>
/// <returns></returns>
public string CreateBarCode(string text, int height, int width, bool showText)
{
string strTemp = text.ToLower();
//替换各个字符
strTemp = strTemp.Replace("0", "_|_|__||_||_|"); ;
strTemp = strTemp.Replace("1", "_||_|__|_|_||");
strTemp = strTemp.Replace("2", "_|_||__|_|_||");
strTemp = strTemp.Replace("3", "_||_||__|_|_|");
strTemp = strTemp.Replace("4", "_|_|__||_|_||");
strTemp = strTemp.Replace("5", "_||_|__||_|_|");
strTemp = strTemp.Replace("7", "_|_|__|_||_||");
strTemp = strTemp.Replace("6", "_|_||__||_|_|");
strTemp = strTemp.Replace("8", "_||_|__|_||_|");
strTemp = strTemp.Replace("9", "_|_||__|_||_|");
strTemp = strTemp.Replace("a", "_||_|_|__|_||");
strTemp = strTemp.Replace("b", "_|_||_|__|_||");
strTemp = strTemp.Replace("c", "_||_||_|__|_|");
strTemp = strTemp.Replace("d", "_|_|_||__|_||");
strTemp = strTemp.Replace("e", "_||_|_||__|_|");
strTemp = strTemp.Replace("f", "_|_||_||__|_|");
strTemp = strTemp.Replace("g", "_|_|_|__||_||");
strTemp = strTemp.Replace("h", "_||_|_|__||_|");
strTemp = strTemp.Replace("i", "_|_||_|__||_|");
strTemp = strTemp.Replace("j", "_|_|_||__||_|");
strTemp = strTemp.Replace("k", "_||_|_|_|__||");
strTemp = strTemp.Replace("l", "_|_||_|_|__||");
strTemp = strTemp.Replace("m", "_||_||_|_|__|");
strTemp = strTemp.Replace("n", "_|_|_||_|__||");
strTemp = strTemp.Replace("o", "_||_|_||_|__|");
strTemp = strTemp.Replace("p", "_|_||_||_|__|");
strTemp = strTemp.Replace("r", "_||_|_|_||__|");
strTemp = strTemp.Replace("q", "_|_|_|_||__||");
strTemp = strTemp.Replace("s", "_|_||_|_||__|");
strTemp = strTemp.Replace("t", "_|_|_||_||__|");
strTemp = strTemp.Replace("u", "_||__|_|_|_||");
strTemp = strTemp.Replace("v", "_|__||_|_|_||");
strTemp = strTemp.Replace("w", "_||__||_|_|_|");
strTemp = strTemp.Replace("x", "_|__|_||_|_||");
strTemp = strTemp.Replace("y", "_||__|_||_|_|");
strTemp = strTemp.Replace("z", "_|__||_||_|_|");
strTemp = strTemp.Replace("-", "_|__|_|_||_||");
strTemp = strTemp.Replace("*", "_|__|_||_||_|");
strTemp = strTemp.Replace("/", "_|__|__|_|__|");
strTemp = strTemp.Replace("%", "_|_|__|__|__|");
strTemp = strTemp.Replace("+", "_|__|_|__|__|");
strTemp = strTemp.Replace(".", "_||__|_|_||_|");
//替换字符中的_和|
strTemp = strTemp.Replace("_", "<span style='height:" + height + ";width:" + width + ";background:#FFFFFF;'></span>");
strTemp = strTemp.Replace("|", "<span style='height:" + height + ";width:" + width + ";background:#000000;'></span>");
if (showText)
{
return strTemp + "<br/>" + text;
}
else
{
return strTemp;
}
}
您可能感兴趣
- ASP.NET实现FTP上传文件
- ASP.NET生成静态页面的方法
- asp.net MVC处理流程
- Asp.net页面传值乱码
- ASP.NET 生成条形码
- asp.net把word文档转换成pdf
- windowsserver2008部署php项目(win2008 r2 服务器环境配置FTP/ASP/ASP.Net/PHP)
- ASP.NET下载远程图片到本地
- asp.net中Session的操作
- ASP.NET中application对象的用法
- asp.net后台输出js脚本
- asp.net如何实现word文档在线预览
- asp.net将ppt文档转换成pdf
- ASP.NET实现多文件上传
- ASP.NET压力测试
- ASP.NET生成二维码
- 谷雨前,吃牛羊肉别忘了吃河鲜,除湿还清热,加紫苏一炒特解馋(吃牛羊肉别忘了吃河鲜)
- 紫苏牛肉锅里滚一滚,香的鼻子都要掉了(紫苏牛肉锅里滚一滚)
- 每天都吃水果的好处(每天吃水果的好处与功效)
- 苹果15价格(苹果15价格512g官网)
- 春节放假几天(春节放假几天2023法定几天)
- 今天 3月13日,31年前,一个英雄少年感动了中国(今天3月13日31年前)
热门推荐
- 还有什么问题要问我们的吗,如何回答
- mysql数据库基本使用方法(详解MySQL 数据库范式)
- html5导入图片文件(HTML5 实现图片上传预处理功能)
- sqlleftjoin详解(SQL JOIN 连接详细介绍及简单使用实例)
- mysqlupdate语句用法(MySQL update set 和 and的区别)
- vue-router底层实现原理(vue-router history模式服务器端配置过程记录)
- linux下如何启动phpstudy面板(详解phpstudy linux web面板小皮面板V0.2版本正式发布)
- sw动态注解视图干嘛的(Swoole 5将移除自动添加Event::wait特性详解)
- python八卦图(Python实现九宫格式的朋友圈功能内附“马云”朋友圈)
- firebug使用方法