首页 > Windows开发 > 详细

C# 生成条形码

时间:2016-10-17 23:24:33      阅读:334      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!