GS1-128

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronBarcode 是否支援 GS1 UCC/EAN-128 條碼系統?

採用 GS1 標準的條碼能夠被準確地辨識和解碼。 然而,問題在於目前顯示的條碼值缺少括號。

使用 GS1-128 時,IronBarcode 目前輸出: 01950123456789033103000123 (被識別為 GS1 簽署的 Code 128 條碼)。 影像輸出上要顯示的值應為: 01950123456789033103000123 。 但是,條碼掃描器將輸出(01)95012345678903(3103)000123 ,偵測到的條碼類型為Code128

若要產生 GS1-128 條碼,請使用下列程式碼:

using IronBarCode;

class BarcodeExample
{
    static void Main()
    {
        // Create a GS1-128 barcode using the specified value
        GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);

        // Add the barcode value text below the barcode on the generated image
        barcode.AddBarcodeValueTextBelowBarcode();

        // Save the barcode image as a PNG file
        barcode.SaveAsPng("gs1code128.png");
    }
}
using IronBarCode;

class BarcodeExample
{
    static void Main()
    {
        // Create a GS1-128 barcode using the specified value
        GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("01950123456789033103000123", BarcodeWriterEncoding.Code128GS1);

        // Add the barcode value text below the barcode on the generated image
        barcode.AddBarcodeValueTextBelowBarcode();

        // Save the barcode image as a PNG file
        barcode.SaveAsPng("gs1code128.png");
    }
}
$vbLabelText   $csharpLabel

輸出條碼

輸出條碼範例

上述程式碼產生帶有預設分隔符號的 GS1-128 條碼。 如果要新增其他分隔符,可以插入 Unicode 分隔符\u00f1 。 但請注意,使用AddBarcodeValueTextBelowBarcode方法時,會顯示 Unicode 字元 ñ(代碼 0x00F1)。 為了克服這個限制,另一種方法是操作字串並將修改後的值傳遞給AddAnnotationTextBelowBarcode方法。 這樣,您就可以在不顯示 ñ 字元的情況下實現所需的條碼值顯示。

using IronBarCode;

class BarcodeExampleWithAnnotation
{
    static void Main()
    {
        // Original barcode value
        string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";

        // Remove unwanted unicode characters for display purposes
        string trimmedString = barcodeValue.Replace("\u00f1", "");

        // Create a GS1-128 barcode using the original value
        GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);

        // Add a custom annotation text below the barcode with the trimmed value
        barcode.AddAnnotationTextBelowBarcode(trimmedString);

        // Save the barcode image as a PNG file
        barcode.SaveAsPng("gs1code128.png");
    }
}
using IronBarCode;

class BarcodeExampleWithAnnotation
{
    static void Main()
    {
        // Original barcode value
        string barcodeValue = "0195012345678903310300012300\u00f10000000123300000\u00f10000012312300000";

        // Remove unwanted unicode characters for display purposes
        string trimmedString = barcodeValue.Replace("\u00f1", "");

        // Create a GS1-128 barcode using the original value
        GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(barcodeValue, BarcodeWriterEncoding.Code128GS1);

        // Add a custom annotation text below the barcode with the trimmed value
        barcode.AddAnnotationTextBelowBarcode(trimmedString);

        // Save the barcode image as a PNG file
        barcode.SaveAsPng("gs1code128.png");
    }
}
$vbLabelText   $csharpLabel

輸出條碼

輸出附註解的條碼範例

掃描條碼時,輸出結果為(01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000 ,條碼類型將被偵測為GS1Code128

柯蒂斯·週
技術撰稿人

Curtis Chau擁有卡爾頓大學電腦科學學士學位,專長於前端開發,精通Node.js、TypeScript、JavaScript和React。他熱衷於打造直覺美觀的使用者介面,喜歡使用現代框架,並擅長撰寫結構清晰、視覺效果出色的使用者手冊。

除了開發工作之外,柯蒂斯對物聯網 (IoT) 也抱有濃厚的興趣,致力於探索硬體和軟體整合的創新方法。閒暇時,他喜歡玩遊戲和製作 Discord 機器人,將他對科技的熱愛與創造力結合。

準備好開始了嗎?
Nuget 下載 2,035,202 | 版本: 2025.12 剛剛發布