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");
    }
}
Imports IronBarCode

Friend Class BarcodeExample
	Shared Sub Main()
		' Create a GS1-128 barcode using the specified value
		Dim barcode As GeneratedBarcode = 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")
	End Sub
End Class
$vbLabelText   $csharpLabel

出力バーコード

出力バーコード例

上記のコードは、デフォルトの区切りを持つ GS1-128 バーコードを生成します。 追加の区切りを追加したい場合は、ユニコード区切り文字 \u00f1 を挿入できます。 ただし、AddBarcodeValueTextBelowBarcode メソッドを使用すると、ユニコード文字 ñ (コード 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");
    }
}
Imports IronBarCode

Friend Class BarcodeExampleWithAnnotation
	Shared Sub Main()
		' Original barcode value
		Dim barcodeValue As String = "0195012345678903310300012300" & ChrW(&H00f1).ToString() & "0000000123300000" & ChrW(&H00f1).ToString() & "0000012312300000"

		' Remove unwanted unicode characters for display purposes
		Dim trimmedString As String = barcodeValue.Replace(ChrW(&H00f1).ToString(), "")

		' Create a GS1-128 barcode using the original value
		Dim barcode As GeneratedBarcode = 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")
	End Sub
End Class
$vbLabelText   $csharpLabel

出力バーコード

注釈付き出力バーコード例

バーコードをスキャンすると、出力は (01)95012345678903(3103)000123(00)0000000123300000(00)00012312300000 になり、バーコードの種類は GS1Code128 として検出されます。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 1,935,276 | バージョン: 2025.11 ただ今リリースされました