条形码 BarCode (C# BarcodeLib.dll)

1  static  void  BuildBarcode()
2        {
3            System.Drawing.Image image;
4            int width=250, height=100;
5            byte[] buffer = GetBarcode(height, width, 
6                     BarcodeLib.TYPE.CODE128, "Avx-(13614)-vR", out image);
7        }
 1      static byte[] GetBarcode(int height, int width,BarcodeLib.TYPE type,
 2                                           string  code,out System.Drawing.Image image)
 3         {
 4             image=null;
 5             BarcodeLib.Barcode b = new BarcodeLib.Barcode();
 6             b.BackColor = System.Drawing.Color.White;
 7             b.ForeColor = System.Drawing.Color.Black;
 8             b.IncludeLabel = true;
 9             b.Alignment = BarcodeLib.AlignmentPositions.CENTER;
10             b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
11             b.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
12             System.Drawing.Font font = new System.Drawing.Font("verdana",10f);
13             b.LabelFont = font;
14 
15             b.Height = height;
16             b.Width = width;
17 
18             image = b.Encode(type, code);
19             SaveImage(image, Guid.NewGuid().ToString("N")+".png");
20             byte[] buffer = b.GetImageData(SaveTypes.GIF);
21             return buffer;
22         }
生成的条形码:

[barcode.dll下载]

转载于:https://www.cnblogs.com/AspDotNetMVC/archive/2012/11/16/2767576.html

你可能感兴趣的:(条形码 BarCode (C# BarcodeLib.dll))