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 になります。 ただし、バーコード スキャナーはバーコード タイプを Code128 として検出し、(01)95012345678903(3103)000123 を出力します。

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に精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

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

準備はできましたか?
Nuget ダウンロード 2,121,847 | バージョン: 2026.3 リリース
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package BarCode
サンプルを実行する 文字列が BarCode になるのを見る。