标签:
原文地址:http://www.cnblogs.com/xcsn/p/4514759.html
引用BarcodeLib.dll(百度云中有)生成条形 protected void Button2_Click(object sender, EventArgs e)//点击button2,生成条形码。
{ System.Drawing.Image image; int width = 148, height = 55; string fileSavePath = AppDomain.CurrentDomain.BaseDirectory + "BarcodePattern.jpg"; if (File.Exists(fileSavePath)) File.Delete(fileSavePath); GetBarcode(height, width, BarcodeLib.TYPE.CODE128, "20131025-136", out image, fileSavePath); //"20131025-136"是条形码的内容,fileSavePath是条形码保存的位置。 }
public static void GetBarcode(int height, int width, BarcodeLib.TYPE type, string code, out System.Drawing.Image image, string fileSaveUrl) { image = null; BarcodeLib.Barcode b = new BarcodeLib.Barcode(); b.BackColor = System.Drawing.Color.White; b.ForeColor = System.Drawing.Color.Black; b.IncludeLabel = true; b.Alignment = BarcodeLib.AlignmentPositions.CENTER; b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER; b.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg; System.Drawing.Font font = new System.Drawing.Font("verdana", 10f); b.LabelFont = font; b.Height = height; b.Width = width; image = b.Encode(type, code); image.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Png); }
标签:
原文地址:http://www.cnblogs.com/vichin/p/5971489.html