【实用技能】如何利用条码控件Aspose.BarCode,控制 Barcode-39 中的宽窄比

概述

控制 Barcode-39 中的宽窄比是条形码配置的一个重要方面。它确保条形码的可读性和准确性,这对从零售到物流等各个行业都至关重要。**Aspose.BarCode for .NET**是一个功能强大的工具,允许开发人员轻松管理此比率,从而为条形码创建提供灵活性和精确度。这篇教程将指导您如何使用 Aspose.BarCode for .NET 控制 Barcode-39 中的宽窄比。

Aspose.BarCode 最新试用下载

库安装

首先,从此链接安装Aspose.BarCode for .NET。使用以下命令进行安装:

复制代码
Install-Package Aspose.BarCode

Aspose.BarCode for .NET 因其易于集成、灵活性和高级定制选项而脱颖而出,使其成为控制 Barcode-39 中宽窄比的理想选择。

带有分步指南的代码片段

要使用 Aspose.BarCode for .NET 控制 Barcode-39 中的宽窄比,请按照以下步骤操作。

  1. 创建BarcodeGenerator的实例。
  2. 使用数值设置Pixels属性。
  3. 通过定义WideNarrowRatio的值将宽/窄比设置为 2 。
  4. Save方法将把条形码保存在磁盘上。

以下代码示例演示了如何以编程方式控制 Barcode-39 的宽窄比:

复制代码
using Aspose.BarCode.Generation;

string path = "/Desktop/";
System.Console.WriteLine("OneCSCode93:");
// Create an instance of BarcodeGenerator. 
BarcodeGenerator gen = new BarcodeGenerator(EncodeTypes.Code39FullASCII, "ASPOSE");
// Set the Pixels property with a numeric value; 
gen.Parameters.Barcode.XDimension.Pixels = 2;
// Set Wide/Narrow Ratio to 2 by defining the value of WideNarrowRatio.
gen.Parameters.Barcode.WideNarrowRatio = 2;
// The Save method will save the barcode on the disk.
gen.Save($"{path}WideNarrow2Code39.png", BarCodeImageFormat.Png);
//set Wide/Narrow Ratio to 5.
gen.Parameters.Barcode.WideNarrowRatio = 5;
// Invoke the Save method to save the barcode on the disk.
gen.Save($"{path}WideNarrow5Code39.png", BarCodeImageFormat.Png);

您可以在下图中看到输出:

结论

现在,您可以通过编程控制 Barcode-39 中的宽窄比。使用 Aspose.BarCode for .NET,您可以轻松管理此比例,确保条形码的可读性和准确性。

相关推荐
码观天工1 小时前
.NET 原生驾驭 AI 新基建实战系列(八):总结篇 ── 数据库技术的革命:从结构化到非结构化再到智能化的演进
ai·c#·.net·向量数据库
编程乐趣6 小时前
5个yyds的.Net商城开源项目
开源·c#·.net
界面开发小八哥15 小时前
界面控件DevExpress WinForms中文教程:Banded Grid View - API
.net·界面控件·winform·devexpress·ui开发·用户界面
编程乐趣15 小时前
一个可拖拉实现列表排序的WPF开源控件
开源·c#·.net·wpf
矿工学编程16 小时前
在宝塔中使用.NET环境管理部署 .NET Core项目
linux·.net
黑洞视界2 天前
NCC Mocha v0.2.0 发布, 新增对 Metrics 的支持
c#·.net·可观测性·observability
喵叔哟2 天前
22.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--单体转微服务--增加公共代码
微服务·架构·.net
python算法(魔法师版)2 天前
.NET NativeAOT 指南
java·大数据·linux·jvm·.net