C# 如何使用ZXing.ImageSharp在条形码下方获得标签?

C# 如何使用ZXing.ImageSharp在条形码下方获得标签?,c#,barcode,zxing.net,imagesharp,C#,Barcode,Zxing.net,Imagesharp,我正在ASP.NET Core 5.0应用程序中使用0.16.9-beta生成Code128条形码 我的问题是,即使指定了PureBarcode=false,我也无法让代码在条形码下方生成文本标签 我创建了两种测试方法: 第一种方法不使用ImageSharp,而是使用System.Drawing。此方法GetBarcode(“123”)按预期工作,并生成带有以下文本标签的条形码: 第二种方法使用ImageSharp。但是,此方法GetBarcodeImageSharp(“123”)不会生成具有

我正在ASP.NET Core 5.0应用程序中使用
0.16.9-beta
生成Code128条形码

我的问题是,即使指定了
PureBarcode=false
,我也无法让代码在条形码下方生成文本标签

我创建了两种测试方法:

  • 第一种方法不使用ImageSharp,而是使用System.Drawing。此方法
    GetBarcode(“123”)
    按预期工作,并生成带有以下文本标签的条形码:
  • 第二种方法使用
    ImageSharp
    。但是,此方法
    GetBarcodeImageSharp(“123”)
    不会生成具有以下文本标签的条形码:
  • 我做错了什么

        [HttpGet]
        [Route("~/getbarcode")]
        public void GetBarcode(string barcode)
        {
            BarcodeWriter writer = new BarcodeWriter
            {
                Format = BarcodeFormat.CODE_128,
                Options = new EncodingOptions
                {
                    Height = 100,
                    Width = 300,
                    Margin = 0,
                    PureBarcode = false
                }
            };           
            writer.Write(barcode).Save(@$"C:\Web\{barcode}.jpg", ImageFormat.Jpeg);
        }
    
        [HttpGet]
        [Route("~/getbarcodeimagesharp")]
        public void GetBarcodeImageSharp(string barcode)
        {
            var barcodeWriter = new ZXing.ImageSharp.BarcodeWriter<Rgba32>
            {
                Format = ZXing.BarcodeFormat.CODE_128,
                Options = new EncodingOptions // have also tried with Code128EncodingOptions but no luck
                {
                    Height = 100,
                    Width = 300,
                    Margin = 0,
                    PureBarcode = false
                }
            };
    
            barcodeWriter.Write(barcode).Save(@$"C:\Web\{barcode}-imagesharp.jpg");
        }
    
    [HttpGet]
    [路线(“~/getbarcode”)]
    公共无效GetBarcode(字符串条形码)
    {
    条形码编写器编写器=新条形码编写器
    {
    格式=条形码格式。代码_128,
    选项=新编码选项
    {
    高度=100,
    宽度=300,
    边距=0,
    PureBarcode=false
    }
    };           
    Write.Write(barcode.Save(@$“C:\Web\{barcode}.jpg”,ImageFormat.Jpeg);
    }
    [HttpGet]
    [路线(“~/getbarcodeimagesharp”)]
    公共无效GetBarcodeImageSharp(字符串条形码)
    {
    var barcodeWriter=新的ZXing.ImageSharp.barcodeWriter
    {
    Format=ZXing.BarcodeFormat.CODE_128,
    Options=newencodingoptions//也尝试过使用Code128EncodingOptions,但没有成功
    {
    高度=100,
    宽度=300,
    边距=0,
    PureBarcode=false
    }
    };
    barcodeWriter.Write(barcode.Save)(@$“C:\Web\{barcode}-imagesharp.jpg”);
    }