生成条形码的代码

来源:互联网 发布:东南大学seu网络登录 编辑:程序博客网 时间:2024/06/03 01:29
b/s(asp.net):先添加引用BarcodeLib.dll,然后再后台写代码:
//生成条形码
               BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
                type = BarcodeLib.TYPE.CODE93;
                try
                {
                    if (type != BarcodeLib.TYPE.UNSPECIFIED)
                    {
                        b.IncludeLabel = IsInclud;
                        b.Encode(type, number, System.Drawing.Color.Black, System.Drawing.Color.White, 200, 70).Save (Server.MapPath("../Photos/carCode.jpg"));
                        imgCarNum.ImageUrl = "~/Photos/carCode.jpg?id=" + rd.Next(1, 1000);
                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message);
                }
c/s(winform): 先添加引用BarcodeLib.dll,然后再后台写代码:
       //生成条形码
        BarcodeLib.Barcode b = new BarcodeLib.Barcode();
        bool IsInclude = true;
        private void CreateBarCode()
        {
            BarcodeLib.TYPE type = BarcodeLib.TYPE.UNSPECIFIED;
            type = BarcodeLib.TYPE.CODE93;
            try
            {
                if (type != BarcodeLib.TYPE.UNSPECIFIED)
                {
                    b.IncludeLabel = IsInclude;
                    pictureBox1.Image = b.Encode(type, "W" + System.DateTime.Now.ToString("yyMMddHHmmss"), Color.Black, Color.White, 200, 100);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
原创粉丝点击