码迷,mamicode.com
首页 > Windows程序 > 详细

C# 生成条形码

时间:2016-10-17 23:27:47      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:

原文地址: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);
}

 

C# 生成条形码

标签:

原文地址:http://www.cnblogs.com/vichin/p/5971489.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!