asp.net 条码 一维条码 生成, 一共有32中格式类型

想用asp.net 实现条码功能,网上找了代码都不全。

终于找到了一个非常全的DLL 是winForm的,原以为不能用在WEB 上结果 可以使用。

首先,引用 DLL 不必说了,下面是 使用设置。还有很多设置 参数,自己琢磨咯。

DLL下载地址  http://pan.baidu.com/s/1jGfwcVc 

示例代码: http://pan.baidu.com/s/1kT7etvD (WinForm版)

下图为 ASP.NET 示例代码:

public ActionResult Test() 
        {
            var bar = new Cobainsoft.Windows.Forms.BarcodeControl();
            bar.AddOnCaption = null;
            bar.AddOnData = null;
            bar.BackColor = System.Drawing.Color.White;
            bar.BarcodeType = Cobainsoft.Windows.Forms.BarcodeType.CODE39;
            bar.Font = new System.Drawing.Font("Arial", 9F);
            bar.ForeColor = System.Drawing.Color.Black;
            bar.HorizontalAlignment = Cobainsoft.Windows.Forms.BarcodeHorizontalAlignment.Center;
            bar.InvalidDataAction = Cobainsoft.Windows.Forms.InvalidDataAction.DisplayInvalid;
            bar.Location = new System.Drawing.Point(3, 3);
            bar.LowerTopTextBy = 0F;
            bar.RaiseBottomTextBy = 0F;
            bar.Size = new System.Drawing.Size(218, 69);



            bar.BarcodeType = Cobainsoft.Windows.Forms.BarcodeType.CODE128C;// 枚举 根据什么格式生成
            bar.ShowCode39StartStop = true;// code39是否有星号
            bar.Data = "88808411"; // 条码数据
            bar.AddOnData = "";// 日期
            bar.TextPosition = Cobainsoft.Windows.Forms.BarcodeTextPosition.Below; // 数据显示在条码底部
            bar.StretchText = true;
            bar.CopyRight = "cydiy";
            
            bar.Invalidate();
            //Stream stream = new FileStream("D://100.png", FileMode.Create, FileAccess.Write, FileShare.None);
            //bar.MakeImage(System.Drawing.Imaging.ImageFormat.Png, 1, 50, true, false, null, stream);
            bar.SaveImage(System.Drawing.Imaging.ImageFormat.Png, 2, 60, true, false, null, "D://1.png");

            return null;
        }

 

posted @ 2014-05-13 01:20  文刀君  阅读(611)  评论(0编辑  收藏  举报