zoukankan      html  css  js  c++  java
  • C# 生成条形码

    原文地址: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);
    }
  • 相关阅读:
    灭霸-个人冲刺第四天
    单词统计
    第十周总结
    灭霸-个人冲刺第三天
    07-代码大全阅读笔记之一
    灭霸-个人冲刺第二天
    灭霸-个人冲刺第一天
    06-梦断代码阅读笔记之三
    团队项目-用户场景分析
    第九周总结
  • 原文地址:https://www.cnblogs.com/vichin/p/5971489.html
Copyright © 2011-2022 走看看