IRONSOFTWAREHOME

GS1-128

Curtis Chau
Curtis Chau
Updated: 2026年4月22日

IronBarcode支援GS1 UCC/EAN-128編碼嗎?

具有GS1的條碼能被精準識別並解碼。 但是,問題出在當前顯示的條碼值中缺少括號。

使用GS1-128時,IronBarcode當前輸出:01950123456789033103000123(這被識別為具有GS1簽名的Code 128條碼)。 希望在輸出圖像上顯示的值是:01950123456789033103000123。 然而,條碼掃描器將輸出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");
    }
}

輸出條碼

輸出條碼範例

上述程式碼生成了一個具有預設分隔符的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");
    }
}

輸出條碼

具有註解的輸出條碼範例

掃描條碼時,輸出將為GS1Code128

分析GS1-128編碼

IronBarcode還可以分析GS1-128條碼的物理編碼,顯示用於資料每個段落的Code 128字元集(A、B或C)。 使用Code128GS1Parser.ParseWithEncoding方法解析包含編碼分析的GS1字串。

using IronBarCode;

// GS1-128 with encoding analysis
var gs1Result = Code128GS1Parser.ParseWithEncoding("(01)09501101530003");
Console.WriteLine(gs1Result.CharacterSetSummary);  // "C"
Console.WriteLine(gs1Result.HasEncodingInfo);      // true

由於GS1-128資料主要是數字,編碼器使用Code C以達到最大緊湊性。 HasEncodingInfo屬性確認編碼分析可在結果中使用。

Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

準備好開始了嗎?

Nuget Downloads 2,422,100版本:2026.9剛剛發布

立即獲取您的免費30天試用金鑰
不需要信用卡或帳戶建立
C# NuGet程式庫,用於PDF
通過NuGet安裝

版本: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. 在解決方案資源管理器中,右鍵點擊References,管理NuGet包
  2. 選擇瀏覽並搜尋"IronBarCode"
  3. 選擇包並安裝
C# PDF DLL
下載DLL

版本: 2026.9

  1. 下載並解壓IronBarCode至您的Solution目錄中的~/Libs等位置
  2. 在Visual Studio解決方案資源管理器中右鍵點擊References,選擇瀏覽,"IronBarCode.dll"

$999起的授權費用

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成下方表單或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立