(一)安装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 条码/span>
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 条形码:
- 首先,使用 EncodeType 作为参数创建BarcodeGenerator类的实例。
- 接下来,指定要编码的文本。
- 之后,以像素为单位设置条形码大小值。
- 最后,使用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 GS1Code128BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.GS1Code128);// Specify the code textgenerator.CodeText = "(01)12345678901231(21)ASPOSE(30)9876";// Specify the X-dimension// the smallest width of the unit of BarCode bars or spacesgenerator.Parameters.Barcode.XDimension.Pixels = 2;// Save the outputgenerator.Save(@"C:FilesGS1Code128.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 UpcaGs1Code128CouponBarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1Code128Coupon);// Specify the code textgenerator.CodeText = "123456789012(8110)ASPOSE";// Specify the X-dimension// the smallest width of the unit of BarCode bars or spacesgenerator.Parameters.Barcode.XDimension.Pixels = 2;// Save the outputgenerator.Save(@"C:FilesGs1CouponUpcaCode128.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 UpcaGs1Code128CouponBarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.UpcaGs1Code128Coupon);// Specify the code textgenerator.CodeText = "123456789012(8110)ASPOSE";// Specify the X-dimension// the smallest width of the unit of BarCode bars or spacesgenerator.Parameters.Barcode.XDimension.Pixels = 2;// Set coupon supplement space 50 pixelsgenerator.Parameters.Barcode.Coupon.SupplementSpace.Pixels = 50;// Set Bar Heightgenerator.Parameters.Barcode.BarHeight.Pixels = 50;// Set Bar Colorgenerator.Parameters.Barcode.BarColor = System.Drawing.Color.Blue;// Set Lable Colorgenerator.Parameters.Barcode.CodeTextParameters.Color = System.Drawing.Color.Red;// Save the outputgenerator.Save(@"C:FilesGs1CouponAppearance.jpg");

以上便是如何在C# 中生成GS1-128 条码,希望能帮到您,除此之外,你有其他方面的需求,也欢迎和我们互动,或这下体验我们更多的产品~
欢迎下载|体验更多Aspose产品
获取更多信息请咨询在线客服 或 加入Aspose技术交流群()
标签:
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!