zxing.dll生成条码

引入zxing.dll

using System;
using System.Drawing;
using ZXing.QrCode;
using ZXing;
using ZXing.Common;


namespace NKO_Printer_Core
{
    public class BarcodeHelper
    { 
        /// <summary>
        /// 返回生成的Bitmap对象
        /// </summary>
        /// <param name="barcodeContent">条码内容</param>
        /// <param name="barcodeFormat">条码格式</param>
        /// <param name="height">条码高度</param>
        /// <param name="width">宽度高度</param>
        /// <returns></returns>
        public static Bitmap CreateBarcode(string barcodeContent,BarcodeFormat barcodeFormat,int height,int width)
        {
            try
            {
                BarcodeWriter writer = new BarcodeWriter();
                EncodingOptions options = new QrCodeEncodingOptions
                {
                    DisableECI = true,
                    CharacterSet = "UTF-8",
                    Width = height,
                    Height = width
                };
                writer.Options = options;
                writer.Format = barcodeFormat;
                return writer.Write(barcodeContent);
               
            }
            catch (Exception e)
            { 
                return null;
            }
        }
    }
}

 下载zxing.dll

posted @ 2016-01-18 16:17  人来人往  阅读(4345)  评论(1编辑  收藏  举报