• .net生成条形码


    1、.net 标准库(.net standard 2.0)

      Nuget添加引用:ZXing.Net生成条形码,ZXing.Net.Bindings.ImageSharp生成图片

    public static string GenerateBarcode(string barcode)
            {
                var barcodeWriter = new ZXing.ImageSharp.BarcodeWriter<Rgba32>
                {
                    Format = BarcodeFormat.CODE_128,
                    Options = new EncodingOptions
                    {
                        Height = 100,
                        Width = 200,
                        PureBarcode = false
                    }
                };
                var name = Guid.NewGuid().ToString().Replace("-", "") + ".png";
                var localRes = AppSettingsHelper.LocalRes;
                var filePath = localRes + name;
                using (var image = barcodeWriter.Write(barcode))
                {
                    image.Save(filePath);
                }
    
                var resUrl = AppSettingsHelper.ResUrl;
                var url = filePath.Replace(localRes, resUrl);
                return url;
            }

    2、.net framework 4.6.1

    public static string GenerateBarcode(string barcode)
            {
                BarcodeWriter writer = new BarcodeWriter();
                writer.Format = BarcodeFormat.CODE_128;
                writer.Options = new ZXing.Common.EncodingOptions
                {
                    Height = 100,
                    Width = 200,
                    PureBarcode = false
                };
    
                Bitmap bitmap = writer.Write(barcode);
                var fileName = Guid.NewGuid().ToString().Replace("-", "") + ".png";
                var localRes = AppSettingsHelper.LocalRes;var filePath = localRes + fileName;
                bitmap.Save(filePath);
                var resUrl = AppSettingsHelper.ResUrl;
                var url = filePath.Replace(localRes, resUrl);
                return url;
            }
  • 相关阅读:
    valgrind的使用
    php开启gzip压缩
    scrapy
    今天几个bug的排查过程
    awk使用多个分割符
    有用的url
    图片延迟加载
    用中间表提高互联网程序的开发效率
    百度技术沙龙
    vs2005/.NET2.0 控件演示之 文件上传 《FileUpload》
  • 原文地址:https://www.cnblogs.com/flywing/p/8979278.html
Copyright © 2020-2023  润新知