使用VintaSoft Barcode .NET SDK分析GS1应用标识符

博客分类:条形码   .NET

2025/06/17

在现代物流、零售、医疗和制造业中,包括应用标识符 (AI) 在内的 GS1 标准已成为条形码数据结构化的通用工具。为了有效使用此类条形码,关键不仅在于读取字符串,还在于正确解析其内容——即选择每个应用标识符及其关联的数据。VintaSoft Barcode .NET SDK 软件产品提供了一个强大的工具,可根据 GS1 标准分析和构建信息。

什么是 GS1 应用标识符以及为什么要分析它们

GS1 应用标识符是条形码中实际数据之前的简短数字前缀(通常为 2-4 位数字)。每个前缀唯一标识信息类型,例如全球贸易项目代码 (GTIN)、生产日期、有效期、重量、序列号等。等等。正确解读这些标识符可以自动从条形码中提取结构化、明确的信息,用于企业流程的会计核算、追踪和自动化。

GS1 标识符支持哪些条形码格式?

GS1 标准及其应用标识符被广泛应用于各种条形码符号系统:

这些是全球大型企业最常使用的格式,以确保端到端的可追溯性和自动化。

VintaSoft Barcode .NET SDK 如何进行 GS1 标识符分析

VintaSoft Barcode .NET SDK 软件包不仅可以快速读取任何类型的条形码,还可以根据 GS1 标准自动解析数据行。

分析的主要阶段:

应用及业务优势

使用 VintaSoft Barcode .NET SDK 分析 GS1 应用标识符,为企业开辟了新的自动化和控制机遇。该解决方案可轻松集成到业务流程链中,简化货物流动的会计核算,并确保高度的数据可靠性。

实际优势包括:

使用此类工具不仅能帮助企业降低成本,还能提高服务质量、加快货物处理速度,并使流程更加透明和现代化。

结论

GS1应用标识符的分析和解析是零售、物流和医疗保健等行业现代自动化和会计流程不可或缺的一部分。

VintaSoft Barcode .NET SDK 提供了一种通用、灵活且高性能的解决方案,用于扫描和分析符合 GS1 全球标准的复杂条形码。VintaSoft 解决方案支持多种格式,可自动解析结构化数据,并可轻松集成到现有系统中,从而帮助企业提高流程透明度并降低运营成本。

有关 VintaSoft Barcode .NET SDK 的功能和集成示例的更多信息,请访问 VintaSoft 官方网站 或联系该公司的支持服务。


以下 C# 代码演示了如何生成包含 GS1 信息的 Code128 条形码图像 (GS1-128),以及如何识别生成的图像中的 GS1-128 条形码:
using System;
using System.Text;

using Vintasoft.Barcode;
using Vintasoft.Barcode.BarcodeInfo;
using Vintasoft.Barcode.GS1;
using Vintasoft.Barcode.SymbologySubsets;
using Vintasoft.Imaging;

/// <summary>
/// Test that shows how to encode the barcode data in GS1 format using the GS1Codec class,
/// create image with GS1-128 barcode,
/// read GS1-128 barcode from image and
/// parse data stored in GS1 format.
/// </summary>
class GS1CodecExample
{

    /// <summary>
    /// Runs the test.
    /// </summary>
    public static void TestGS1Codec()
    {
        bool valueVisible = true;

        // form the GS1 Application identifiers

        GS1ApplicationIdentifierValue[] aiValues = new GS1ApplicationIdentifierValue[4];
        GS1ApplicationIdentifier ai;
        // 01 - Global Trade Item Number
        ai = GS1ApplicationIdentifiers.FindApplicationIdentifier("01");
        aiValues[0] = new GS1ApplicationIdentifierValue(ai, "0123456789123C");
        // 310 - Net weight, kilograms
        ai = GS1ApplicationIdentifiers.FindApplicationIdentifier("310");
        aiValues[1] = new GS1ApplicationIdentifierValue(ai, "0012.55");
        // 30 - Count of Items
        ai = GS1ApplicationIdentifiers.FindApplicationIdentifier("30");
        aiValues[2] = new GS1ApplicationIdentifierValue(ai, "10");
        // 90 - Company Internal Information
        ai = GS1ApplicationIdentifiers.FindApplicationIdentifier("90");
        aiValues[3] = new GS1ApplicationIdentifierValue(ai, "ABCabc12345");

        // get GS1 printable value
        StringBuilder printableValue = new StringBuilder();
        foreach (GS1ApplicationIdentifierValue value in aiValues)
            printableValue.Append(value);


        // create the barcode writer
        using (BarcodeWriter writer = new BarcodeWriter())
        {
            // specify that writer must create output image as 24-bpp image
            writer.Settings.PixelFormat = BarcodeImagePixelFormat.Bgr24;

            // specify that writer must generate Code128 barcode
            writer.Settings.Barcode = BarcodeType.Code128;

            // encode GS1 value in GS1-128 symbology
            writer.Settings.Value = GS1Codec.GS1_128.Encode(aiValues, writer.Settings);
            // set printable value
            if (valueVisible)
            {
                writer.Settings.ValueVisible = true;
                writer.Settings.PrintableValue = printableValue.ToString();
            }
            else
            {
                writer.Settings.ValueVisible = false;
            }

            // create image with barcode
            using (VintasoftBitmap barcodeImage = writer.GetBarcodeAsVintasoftBitmap())
            {
                // delete aiValues array
                aiValues = null;

                // create barcode reader
                using (BarcodeReader reader = new BarcodeReader())
                {
                    // specify that reader must search for GS1-128 barcodes only

                    reader.Settings.ScanBarcodeTypes = BarcodeType.None;
                    reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.GS1_128);

                    // read barcode from image
                    IBarcodeInfo[] infos = reader.ReadBarcodes(barcodeImage);

                    // gets a GS1 Application identifiers from barcode value
                    aiValues = ((GS1BarcodeInfo)infos[0]).ApplicationIdentifierValues;

                    printableValue = new StringBuilder();

                    // print Application identifiers values
                    for (int i = 0; i < aiValues.Length; i++)
                    {
                        GS1ApplicationIdentifierValue aiValue = aiValues[i];
                        ai = aiValue.ApplicationIdentifier;
                        Console.WriteLine(string.Format("[{0}] {1}", i + 1, aiValue));
                        Console.WriteLine(string.Format("Application identifier   : {0}", ai.ApplicationIdentifier));
                        Console.WriteLine(string.Format("Value                    : {0}", aiValue.Value));
                        Console.WriteLine(string.Format("Data title               : {0}", ai.DataTitle));
                        Console.WriteLine(string.Format("Data content             : {0}", ai.DataContent));
                        Console.WriteLine(string.Format("Format                   : {0}", ai.Format));
                        Console.WriteLine(string.Format("Is contains decimal point: {0}", ai.IsContainsDecimalPoint));
                        Console.WriteLine(string.Format("Is variable length       : {0}", ai.IsVariableLength));
                        Console.WriteLine();
                        printableValue.Append(aiValue.ToString());
                    }

                    // print GS1 printable value
                    Console.WriteLine("Printable GS1 value: " + printableValue.ToString());
                }
            }
        }
    }
}