• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

条码控件Aspose.BarCode入门教程6在C# 生成GS1-128 条码

武飞扬头像
爱分享的小妮子
帮助1

Aspose.BarCode for .NET 是一个功能强大的API,可以从任意角度生成和识别多种图像类型的一维和二维条形码。开发人员可以轻松添加条形码生成和识别功能,以及在.NET应用程序中将生成的条形码导出为高质量的图像格式。

Aspose API支持流行文件格式处理,并允许将各类文档导出或转换为固定布局文件格式和最常用的图像/多媒体格式。

我们都知道,条码是识别商品的图形符号。GS1-128 条形码在零售业中非常普遍。GS1-128 标准促进了全球公司之间的数据交换。从本质上讲,它是一种电子商务技术标准,用于提供有关产品的准确可靠信息。在本文中,我们将学习如何生成 GS1-128 条形码。完成上述步骤后,我们将在 C# 中拥有自己的 GS1-128 条码生成器。让我们开始吧。

(一)安装C# GS1-128 条码生成器 API

为了生成 GS1-128 条形码,我们将使用Aspose.BarCode for .NET API。它允许生成和识别范围广泛的 1D 和 2D条码类型。

API的BarcodeGenerator类允许生成指定 EncodeType 的条形码。EncodeType类允许指定要编码的条形码类型。我们可以使用此类的Save(string)方法保存生成的条形码图像。

请下载API 的 DLL 或使用NuGet安装它。

PM> Install-Package Aspose.BarCode

(二)什么是 GS1-128 条码?

GS1-128(以前称为 UCC/EAN-128)条码是一种机器可读的产品识别码,用于存储数据并提供有关产品的信息。此代码适用于货物的包装和容器,以帮助促进食品的有效分配和使用。

全球数以千计的行业使用 GS1 条形码或全球贸易项目代码 (GTIN)。全球的客户和供应商都知道食品、药品和其他商品的 GS1-128 条码。它作为制造商、零售商和消费者的库存管理工具。GS1-128 代码由国际标准化组织 (ISO) 定义并由 GS1 组织发布。

(三)了解 GS1-128 条码

GS1-128 条形码遵循以下格式:

(Application_Identifier_1)Application_Data(Application_Identifier_2)Application_Data

GS1-128 条形码包含以下有用信息:

  • GTIN(全球贸易项目编号)
  • 序列号
  • 批号和批号
  • 产品日期
  • 产品的来源和目的地
  • 产品性质

(四)在 C# 中生成 GS1-128 条码

我们可以按照以下步骤生成 GS1-128 条形码:

  1. 首先,使用 EncodeType 作为参数创建BarcodeGenerator实例。
  2. 接下来,指定要编码的文本。
  3. 之后,以像素为单位设置条形码大小值。
  4. 最后,使用Save()方法保存输出。它以输出文件路径作为参数。

以下代码示例显示如何在 C# 中生成 GS1-128 条形码

// This code example demonstrates how to generate a GS1-128 barcode.
// Create an instane of the BarcodeGenerator class
// Specify Encode type as GS1Code128
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128);

// Specify the code text
generator.CodeText = "(01)12345678901231(21)ASPOSE(30)9876";

// Specify the X-dimension
// the smallest width of the unit of BarCode bars or spaces
generator.Parameters.Barcode.XDimension.Pixels = 2;

// Save the output
generator.Save(@"C:\Files\GS1Code128.jpg");

学新通

(五)在 C# 中生成 UPC-A GS1 128 优惠券

同样,我们可以按照前面提到的步骤生成一个条形码标签,在同一图像中放置一个额外的 GS1-128 优惠券条形码。但是,我们需要在第一步中将 EncodeType设置为UpcaGs1Code128Coupon 。

以下代码示例显示如何在 C# 中生成 UPC-A GS1 代码 128 优惠券

// This code example demonstrates how to generate a UPC-A GS1 Code 128 Coupon.
// Create an instane of the BarcodeGenerator class
// Specify Encode type as UpcaGs1Code128Coupon
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1Code128Coupon);

// Specify the code text
generator.CodeText = "123456789012(8110)ASPOSE";

// Specify the X-dimension
// the smallest width of the unit of BarCode bars or spaces
generator.Parameters.Barcode.XDimension.Pixels = 2;

// Save the output
generator.Save(@"C:\Files\Gs1CouponUpcaCode128.jpg");

学新通

(六)在 C# 中自定义 GS1 128 优惠券外观

我们还可以按照前面提到的步骤自定义条形码的外观。但是,在最后一步保存图像之前,我们需要指定其他属性。

以下代码示例显示如何在 C# 中自定义 GS1 128 优惠券的条形码外观

// This code example demonstrates how to customize the barcode appearance of GS1 128 Coupon.
// Create an instane of the BarcodeGenerator class
// Specify Encode type as UpcaGs1Code128Coupon
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1Code128Coupon);

// Specify the code text
generator.CodeText = "123456789012(8110)ASPOSE";

// Specify the X-dimension
// the smallest width of the unit of BarCode bars or spaces
generator.Parameters.Barcode.XDimension.Pixels = 2;

// Set coupon supplement space 50 pixels
generator.Parameters.Barcode.Coupon.SupplementSpace.Pixels = 50;

// Set Bar Height
generator.Parameters.Barcode.BarHeight.Pixels = 50;

// Set Bar Color
generator.Parameters.Barcode.BarColor = System.Drawing.Color.Blue;

// Set Lable Color
generator.Parameters.Barcode.CodeTextParameters.Color = System.Drawing.Color.Red;

// Save the output
generator.Save(@"C:\Files\Gs1CouponAppearance.jpg");
学新通

学新通

以上便是如何在C# 中生成GS1-128 条码,希望能帮到您,除此之外,你有其他方面的需求,也欢迎和我们互动,

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgbifgf
系列文章
更多 icon
同类精品
更多 icon
继续加载