【实用技能】如何利用条码控件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,您可以轻松管理此比例,确保条形码的可读性和准确性。

相关推荐
_Jonas26 分钟前
.net framework开发环境正式环境配置文件的切换
.net·wpf
Y3815326622 天前
C# 调用谷歌搜索 API:HttpClient 与 System.Text.Json 实战
搜索引擎·.net
qq_410194292 天前
.NET 8.0 下基于 PaddleOCRSharp 的离线文字识别落地指南
算法·.net
唐青枫4 天前
别急着拆服务:C#.NET 微服务架构从边界设计到实战
c#·.net
唐青枫5 天前
别把 Razor 当成几段 HTML:C#.NET Razor Pages、MVC 视图与实战详解
c#·.net
宝桥南山5 天前
Microsoft Fabric - 简单尝试一下Microsoft Fabric .NET SDK
microsoft·微软·.net·.netcore·powerbi·fabric
Lost of 程序猿5 天前
.NET 10 船端单机部署与离线升级实战:从闪退事故到无感回滚
c#·asp.net·.net
慧都小妮子5 天前
Word/Excel/PPT 如何稳定导出 Markdown?文档 SDK 三线能力拆解
.net·markdown·知识库·aspose·rag·文档转换·文档互操作
唐青枫6 天前
对象到底住在哪里?C#.NET 托管堆从分配、GC 到内存排查
c#·.net
geovindu6 天前
CSharp:Condition Variable Pattern
后端·设计模式·c#·.net·.netcore·条件变量模式·同步型模式