IronBarcode 操作指南 建立一維 BarCode 如何建立一維和直線條碼 Curtis Chau 更新:2026年1月10日 下載 IronBarcode NuGet 下載 DLL 下載 開始免費試用 法學碩士副本 法學碩士副本 將頁面複製為 Markdown 格式,用於 LLMs 在 ChatGPT 中打開 請向 ChatGPT 諮詢此頁面 在雙子座打開 請向 Gemini 詢問此頁面 在 Grok 中打開 向 Grok 詢問此頁面 打開困惑 向 Perplexity 詢問有關此頁面的信息 分享 在 Facebook 上分享 分享到 X(Twitter) 在 LinkedIn 上分享 複製連結 電子郵件文章 This article was translated from English: Does it need improvement? Translated View the article in English IronBarcode 可讓您使用簡單的 C# 程式碼產生所有主要的一維條碼格式,包括 Code 128、GS1-128、Code 39、Code 93、EAN-13、EAN-8、UPC-A、UPC-E、Intelligent Mail、MSI、Codabar 和 DataBar,並具備自動驗證和符合性檢查功能。 您可以探索 支援的 BarCode 格式的完整清單,找到適合您需求的格式。 線性 BarCode 仍然是傳遞資訊的業界標準。 這些工具快速、可靠,幾乎可搭配任何掃描器使用。 由於這些 BarCode 不需要進行複雜的影像處理,因此在零售收銀線和輸送帶等高速環境中表現優異。 主要的挑戰是針對您的特定需求選擇正確的格式。 您可能需要 Code128 的高資料密度用於貨運標籤,EAN8 的精巧尺寸用於小型產品,或 IntelligentMail BarCode 的嚴格格式用於郵政服務。 IronBarcode 可幫助您高效可靠地生成所有這些格式。 該資料庫也支援各種 輸出資料格式,以便與您現有的系統無縫整合。 本指南涵蓋如何使用 IronBarcode 生成最重要的一維格式及其常見用例。 <! -- --> <!--說明:螢幕截圖或圖表 --> 快速入門:創建您的第一個一維條碼。 使用 IronBarcode 的簡單 API,從字串建立 Code128 條碼並將其儲存為 JPEG 影像。 立即開始 - 提供資料、選擇編碼和大小,並撰寫您的影像檔案。 立即開始使用 NuGet 建立 PDF 檔案: 使用 NuGet 套件管理器安裝 IronBarcode PM > Install-Package BarCode 複製並運行這段程式碼。 IronBarCode.BarcodeWriter.CreateBarcode("HELLO-WORLD-123", BarcodeEncoding.Code128, 250, 100).SaveAsJpeg("MyFirstBarcode.jpg"); 部署到您的生產環境進行測試 立即開始在您的專案中使用 IronBarcode,免費試用! 免費試用30天 ## 如何使用 IronBarcode 建立一維和線性條碼 下載 IronBarcode C# 函式庫以建立條碼。 使用CreateBarcode產生帶有字串值的條碼 使用 BarcodeEncoding 指定條碼類型 使用 SaveAsJpeg 將條碼儲存為影像或其他格式 <! -- --> --> <!--說明:顯示程式碼執行輸出或結果的截圖 --> 如何建立一維和直線條碼? 線性一維 BarCode 使用可變寬度的線和空格來水平儲存資料。 二維條碼(如 QR code)使用方格網格來保存二維資訊。 二維編碼可容納更多的資料,例如 URL 或聯絡卡片,而一維 BarCode 則只能使用簡短的字母數字字串。 這種簡易性可讓一維 BarCode 更快速地掃描。 它使這些工具與標準雷射掃描器普遍相容,是高速零售和物流環境的理想選擇。 在處理大量掃描應用程式時,請探索我們的 讀取速度選項,以最佳化效能。 讓我們來探討最受支援的格式,以及如何使用 IronBarcode 建立這些格式。 如何建立 Code-128 BarCode? Code 128 BarCode 常用於內部物流和運送標籤。 它支援完整的 128 個字元 ASCII 範圍,因此能高效率地將標準數字和英文文字壓縮到小空間內。 這使得 Code 128 成為倉庫管理系統和庫存追蹤的理想選擇,在這些系統中,空間有限,但資料密度卻非常重要。 然而,在沒有額外擴充的情況下,它無法原生支援 Unicode 或非拉丁字符。 它無法處理中文或阿拉伯文等語言的複雜字元,並會誤解資料,導致不正確的輸出。 對於需要 Unicode 支援的應用程式,請參閱我們的 撰寫 Unicode BarCode 指南。 我需要哪些程式碼? IronBarcode 可以直接生成 Code-128:在呼叫 Create 方法時,將 BarcodeEncoding.Code128 作為第二個參數傳入,然後匯出為影像。 進一步了解 使用各種格式和選項建立條碼影像。 :path=/static-assets/barcode/content-code-examples/how-to/create-code-128-barcode.cs using IronBarCode; // Specify Code 128 Format GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128); // Add barcode value text below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save it as JPG barcode.SaveAsJpeg("code128-sample.jpg"); Imports IronBarCode ' Specify Code 128 Format Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode/", BarcodeEncoding.Code128) ' Add barcode value text below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save it as JPG barcode.SaveAsJpeg("code128-sample.jpg") $vbLabelText $csharpLabel 輸出是什麼樣子? 如何建立 GSI-128 BarCode? GS1-128 是應用在 Code 128 之上的附加資料格式。GS1-128 的主要優勢在於全球一致的資料詮釋,消除誤解和歧義。 這種標準化對於產品在不同公司和國家之間移動的供應鏈管理至關重要。 然而,由於格式要求嚴格,若遺漏隱藏控制字元或欄位長度不正確,都會使 BarCode 不符合規範。 如果您遇到 GS1-128 格式化的問題,我們的 GS1-128 疑難排解指南 可協助您解決常見問題。 GSI-128 要求什麼格式? BarCode 掃描器使用應用程式識別碼 (Application Identifiers, AI) - 識別產品代碼中資訊的數字前綴。 瞭解這些識別碼對於建立可在全球供應鏈中運作的合規 BarCode 至關重要。 GS1-128 遵循此四部分資料結構: (數字前綴 01)GTIN(全球貿易項目號碼):唯一的產品 ID,可識別該產品是什麼。 必須是準確的 14 位數字。 如果您的產品代碼較短,請填充前導零。 例如,123456789012 變成 00123456789012。 (數字前綴 10)Batch/Lot:產品的批次或批號。 1 到 20 個字母數字字符。 當放置在 BarCode 中間時,需要 FNC1 分隔符,以便掃描器知道其結束位置。 如果在 BarCode 端,則不需要分隔符。 (數字前綴 17)到期日:產品的到期日。 按照 YYMMDD 格式固定為六位數。 例如,251231 就是 2025 年 12 月 31 日。使用 2 位數的年份與世紀滑動視窗。 (數字前綴 21)序號:識別獨特個別單位的產品序號。 長度可變,包含 1-20 個字母數字字符。 請注意Only the GTIN is required; 批次、到期日和序列屬性為選項。 警告雖然只需要 GTIN,但有些零售商有特定的合規指引。 在建立 BarCode 時檢查它們的要求。 如何使用 IronBarcode 生成 GSI-128? 生成 GS1-128 BarCode 非常簡單; 在呼叫 Create 時,傳入 BarcodeEncoding.Code128GS1 作為第二個參數。 以下範例顯示符合 GS1-128 標準的完整值,包含所有四種屬性,並將其匯出為影像。 請注意每個數字前綴都必須加上圓括號,否則該部分將不會被識別為有效的屬性。 [{i:(IronBarcode 在建立 GSI-128 時會自動插入 FNC1 分隔符。 :path=/static-assets/barcode/content-code-examples/how-to/create-gsi-128-barcode.cs using IronBarCode; // Valid GS1-128 String: GTIN + Expiry + Batch + Serial Number string gs1Value = "(01)01234567890128(17)251231(10)BATCH001(21)111111"; // Create the barcode GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(gs1Value, BarcodeEncoding.Code128GS1); // Display the value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("gsi128-sample.jpg"); Imports IronBarCode ' Valid GS1-128 String: GTIN + Expiry + Batch + Serial Number Dim gs1Value As String = "(01)01234567890128(17)251231(10)BATCH001(21)111111" ' Create the barcode Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(gs1Value, BarcodeEncoding.Code128GS1) ' Display the value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("gsi128-sample.jpg") $vbLabelText $csharpLabel GSI-128 的輸出是什麼樣子? 如何修正 GSI-128 格式錯誤? 如果您的字串不符合 GS1-128 標準,IronBarcode 會產生異常。 使用上表驗證您的字串值,並據此修改。 如何建立 Code 39 BarCode? Code 39 是最早的字母數字條碼標準之一,以可靠性著稱。 常見於汽車和國防領域。 它能夠對字母和數字進行編碼,而無需校驗位元,這使得它在通過其他方式驗證資料完整性的環境中非常簡單。 然而,Code 39 的字元集有限。 它只允許大寫的英文字元、數字和符號,如 /、.、- 等。標準模式不支援小寫。 如需閱讀標準與擴充 Code 39 條碼的相關資訊,請參閱我們的 Code 39 閱讀指南。 Code 39 需要哪些程式碼? 若要產生 Code39,請在使用 Create 時將 BarcodeEncoding.Code39 傳送為第二個參數。 以下是一個範例: :path=/static-assets/barcode/content-code-examples/how-to/create-code-39-barcode.cs using IronBarCode; // Specify Code39 Format GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("IRON-1234", BarcodeEncoding.Code39); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("code39.jpg"); Imports IronBarCode ' Specify Code39 Format Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode("IRON-1234", BarcodeEncoding.Code39) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("code39.jpg") $vbLabelText $csharpLabel Code 39 輸出是什麼樣子? 為什麼我會收到 Code 39 錯誤? 如果字串不符合 Code39 標準,IronBarcode 會拋出此異常。 [{w:(IronBarcode目前不支援產生延伸的Code39條碼; 僅支援閱讀。 有關閱讀擴展和標準 Code39,請參閱我們的 Code 39 閱讀教學。 如何建立 Code 93 BarCode? Code 93 改進了 Code 39,常用於空間有限但需要字母數字資料的物流和電子元件標籤。 提高的密度適合空間重要的小型電子元件。 它接受完整的 ASCII 字元、大寫英文字母、數字和符號。 提供比 Code 39 更高的密度。 Code 93 需要哪些程式碼? 若要產生 Code93,請在使用 Create 時將 BarcodeEncoding.Code93 傳送為第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-code-93-barcode.cs using IronBarCode; // Valid Input: Uppercase A-Z, 0-9, specific symbols string code93Value = "ELEC-COMP-99"; // Create Code 93 GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(code93Value, BarcodeWriterEncoding.Code93); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("code93.jpg"); Imports IronBarCode ' Valid Input: Uppercase A-Z, 0-9, specific symbols Dim code93Value As String = "ELEC-COMP-99" ' Create Code 93 Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(code93Value, BarcodeWriterEncoding.Code93) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("code93.jpg") $vbLabelText $csharpLabel Code 93 輸出是什麼樣子? 如何建立 CodaBar BarCode? Codabar 對於印刷品質不佳的問題非常堅固,廣泛應用於血庫和圖書館。 格式的容錯能力非常適合低品質印表機或磨損的情況。 可變長但有限的字元集。 僅包含數字 (0-9) 和符號 (-, $, :, /, ., +). 開始/停止符號 A、B、C、D 表示開始或結束。 這些字元不能出現在 BarCode 中間。 CodaBar需要哪些程式碼? 若要產生 Codabar,請在使用 Create 時傳入 BarcodeEncoding.Codabar 作為第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-codabar-barcode.cs using IronBarCode; // Valid Input: Numbers 0-9 and symbols -$:/.+ IronBarcode automatically appends by A, B, C, or D string codabarValue = "10500200"; // Create Codabar GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(codabarValue, BarcodeWriterEncoding.Codabar); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("codabar.jpg"); Imports IronBarCode ' Valid Input: Numbers 0-9 and symbols -$:/.+ IronBarcode automatically appends by A, B, C, or D Dim codabarValue As String = "10500200" ' Create Codabar Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(codabarValue, BarcodeWriterEncoding.Codabar) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("codabar.jpg") $vbLabelText $csharpLabel CodaBar 的輸出是什麼樣子? 為什麼 CodaBar 會產生錯誤? 如果輸入包含字母,IronBarcode 會產生異常,說明它只接受數值。 如何建立 DataBar BarCode? GS1 DataBar (前身為 RSS-14)較為精簡,專為產品識別碼所設計。 對於新鮮農產品等小件商品非常有用,因為傳統的 BarCode 佔用太多空間。 在我們的新格式里程碑更新中瞭解更多有關更新格式功能的資訊。 如同 GS1-128,它有嚴格的編碼格式。 Omnidirectional 變體包含 僅產品代碼屬性。 GS1-DataBar 需要什麼格式? (數字前綴-01)GTIN(全球貿易項目碼):唯一的產品 ID。 必須是準確的 14 位數字。 警告標準"GS1 DataBar Omnidirectional"只能容納GTIN(01)。 使用 GS1 DataBar Expanded 取得額外屬性。 如何產生 GS1 DataBar 編碼? 若要產生 GS1 DataBar,請在使用 Create 時傳入 BarcodeEncoding.DataBar 作為第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-gs1-databar-barcode.cs using IronBarCode; // Valid Input: Exactly 14 digits (GTIN). IronBarcode will calculate and append the correct check digit. string databarValue = "0123456789012"; // Create GS1 DataBar GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(databarValue, BarcodeWriterEncoding.DataBar); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("databar.jpg"); Imports IronBarCode ' Valid Input: Exactly 14 digits (GTIN). IronBarcode will calculate and append the correct check digit. Dim databarValue As String = "0123456789012" ' Create GS1 DataBar Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(databarValue, BarcodeWriterEncoding.DataBar) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("databar.jpg") $vbLabelText $csharpLabel DataBar 輸出是什麼樣子? 如何建立 EAN-13 BarCode? EAN-13 是全球用於消費性產品的標準零售條碼,也是使用最廣泛的格式之一。 針對零售應用程式,探討如何 客製化條碼樣式以符合品牌需求。 EAN-13 需要嚴格的授權。 若未取得 GS1 公司前綴授權以確保獨特的 BarCode,則無法產生供公眾使用的 EAN-13 編號。 只包含 13 位數字。 如需授權資訊,請造訪我們的 授權頁面。 EAN-13 有特定的格式規則。 EAN-13 需要什麼格式? EAN-13 BarCode 由四個部分組成: GS1前綴(前3位數):識別GS1成員組織,通常是註冊國家。 範例:000-019 (美國/加拿大 - UPC 相容)、500-509 (英國)、450-459 (日本)。 製造商代碼:由 GS1 指定的長度可變的代碼。 產品代碼:由製造商指定給特定項目。 校驗碼(最後一位數):使用 Modulo 10 演算法從前 12 位數計算。 確保掃描器讀取準確。 [{w:(前綴 200-299 保留為限制流通。 生成 EAN-13 BarCode 時,請勿在生產中使用這些前綴。 如何產生 EAN-13 碼? 若要產生 EAN-13,請在使用 Create 時將 BarcodeEncoding.EAN13 傳作第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-ean13-barcode.cs using IronBarCode; // Valid Input: 12 digits (library calculates 13th check digit) or full 13 digits. string ean13Value = "4006381333931"; // Create EAN-13 GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(ean13Value, BarcodeWriterEncoding.EAN13); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("ean13.jpg"); Imports IronBarCode ' Valid Input: 12 digits (library calculates 13th check digit) or full 13 digits. Dim ean13Value As String = "4006381333931" ' Create EAN-13 Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(ean13Value, BarcodeWriterEncoding.EAN13) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("ean13.jpg") $vbLabelText $csharpLabel EAN-13 輸出是什麼樣子? 如何修正 EAN-13 格式錯誤? IronBarcode 會針對非數字值產生異常。 如何建立 EAN-8 BarCode? EAN-8 是 EAN-13 的精簡版本,適用於全尺寸條碼佔用太多空間的小型消費產品。 常見於包裝空間有限的鉛筆和化妝品上。 與 Code 128 或 Code 39 不同,EAN-8 使用特定指定的前綴,而非任意的數字。 EAN-8 使用嚴格的 8 位數格式:7 個資料位元和 1 個校驗位元。 僅限數字。 EAN-8需要哪些程式碼? 創建 EAN-8 需要在使用 Create 時傳入 BarcodeEncoding.EAN8 到第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-ean8-barcode.cs using IronBarCode; // Valid Input: 7 digits (library calculates 8th check digit). string ean8Value = "1234567"; // Create EAN-8 GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(ean8Value, BarcodeWriterEncoding.EAN8); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("ean8.jpg"); Imports IronBarCode ' Valid Input: 7 digits (library calculates 8th check digit). Dim ean8Value As String = "1234567" ' Create EAN-8 Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(ean8Value, BarcodeWriterEncoding.EAN8) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("ean8.jpg") $vbLabelText $csharpLabel EAN-8 輸出是什麼樣子? 為什麼我會收到 EAN-8 長度錯誤? 如果輸入包含 8 個以上的數字字符,IronBarcode 會產生異常,說明 EAN-8 需要 8 個字元。 如何建立智慧型郵件 BarCode? Intelligent Mail BarCode (IMB) 是 USPS 用於自動化郵件分類與追蹤的標準。 與傳統的寬度調變條碼不同,IMB 使用高度調變條碼。 必須提供信件和單位的自動化價格折扣。 僅支援特定的數字長度:20、25、29 或 31 位數。 使用特定的數字前綴來定義資訊。 智慧型郵件需要什麼格式? (First 2 Digits) BarCode ID:條碼識別符。 嚴格要求 2 位數字。 通常 00 用於標準商業郵件。 (下三個數位)服務類型 ID (STID):定義郵件類別 (如 First Class、Marketing Mail) 和服務 (如 Address Correction、Tracking)。 對於郵政折扣至關重要。 (下一個 6 或 9 位數)Mailer ID (MID):USPS 分配給貴公司的 6 或 9 位數號碼。 (下一個 6 或 9 位數)序號:識別獨特的個別郵件。 (最後 0、5、9 或 11 位數)路由代碼:送貨郵遞區號。 如何產生智慧型郵件代碼? 若要產生 IMB,請在呼叫 Create 時,將 BarcodeEncoding.IntelligentMail 傳作第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-imb-barcode.cs using IronBarCode; // Valid Input: 20, 25, 29, or 31 digits. // Format: Barcode ID(2) + Service(3) + Mailer ID(6/9) + Serial(9/6) + Routing Zip(0/5/9/11) string imbValue = "00270123456200800001"; // Create Intelligent Mail GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(imbValue, BarcodeWriterEncoding.IntelligentMail); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("imb.jpg"); Imports IronBarCode ' Valid Input: 20, 25, 29, or 31 digits. ' Format: Barcode ID(2) + Service(3) + Mailer ID(6/9) + Serial(9/6) + Routing Zip(0/5/9/11) Dim imbValue As String = "00270123456200800001" ' Create Intelligent Mail Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(imbValue, BarcodeWriterEncoding.IntelligentMail) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("imb.jpg") $vbLabelText $csharpLabel 智慧型郵件輸出是什麼樣子? 如何修正智慧型郵件格式錯誤? 如果格式不正確,IronBarcode 會產生異常。 根據上述格式驗證字串值,並在修改後重試。 如何建立 MSI BarCode? MSI 常用於零售貨架標籤和倉庫庫存控制,很少用於消費性產品。 其簡單性及可靠性使其在內部作業中廣受歡迎。 有關 MSI 識別問題,請查看我們的 MSI BarCode 疑難排解指南。 MSI 僅限數字; 不允許使用字母或符號。 長度不定,通常為 10-15 位數。 MSI 需要哪些程式碼? 若要產生 MSI,請在呼叫 Create 時,將 BarcodeEncoding.MSI 傳作為第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-msi-barcode.cs using IronBarCode; // Valid Input: Numeric digits only. Variable length. string msiValue = "1234567890"; // Create MSI GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(msiValue, BarcodeWriterEncoding.MSI); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("msi.jpg"); Imports IronBarCode ' Valid Input: Numeric digits only. Variable length. Dim msiValue As String = "1234567890" ' Create MSI Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(msiValue, BarcodeWriterEncoding.MSI) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("msi.jpg") $vbLabelText $csharpLabel MSI 輸出是什麼樣子? 如何建立 UPC-A BarCode? UPC-A 是美國和加拿大的標準零售 BarCode。 EAN-13 的 12 位數子集。在北美超市的產品上最常見。 廣泛的採用使其對北美市場至關重要。 就像 EAN-13,通常是指派而非產生。 UPC-A 包含正好 12 位數字。 不接受信件。 UPC-A 需要什麼格式? Number System Character (1):識別產品類型(0、1、6、7、8 表示標準零售; 隨機權重 2; 3 種藥物; 5 贈券)。 製造商代碼 (5):由 GS1 指定。 產品代碼 (5):由製造商指定。 校驗碼 (1):計算的 modulo 10 檢查和。 如何產生 UPC-A 碼? 若要產生 UPC-A,請在呼叫 Create 時,將 BarcodeEncoding.UPCA 傳作第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-upc-a-barcode.cs using IronBarCode; // Valid Input: 11 digits (library calculates 12th check digit) or full 12 digits. string upcaValue = "01234567890"; // Create UPC-A GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(upcaValue, BarcodeWriterEncoding.UPCA); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG barcode.SaveAsJpeg("upca.jpg"); Imports IronBarCode ' Valid Input: 11 digits (library calculates 12th check digit) or full 12 digits. Dim upcaValue As String = "01234567890" ' Create UPC-A Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(upcaValue, BarcodeWriterEncoding.UPCA) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG barcode.SaveAsJpeg("upca.jpg") $vbLabelText $csharpLabel UPC-A 輸出是什麼樣子? 為什麼我會收到 UPC-A 長度錯誤? 如果數值長度超過 13,IronBarcode 會產生錯誤。 如何建立 UPC-E BarCode? UPC-E 是小巧的 UPC-A 版本,適用於小型零售包裝,例如汽水罐,因為完整的 12 位元 UPC-A 太大。 壓縮演算法以大約一半的空間來編碼相同的資訊。 如同 UPC-A,嚴格使用數字。 不接受字母或符號。 UPC-E 需要哪些程式碼? 若要產生 UPC-E,請在呼叫 Create 時傳入 BarcodeEncoding.UPCE 作為第二個參數: :path=/static-assets/barcode/content-code-examples/how-to/create-upc-e-barcode.cs using IronBarCode; // Valid Input:8 digits or less, which the last digit is a check digit calculated from the first 7 digits. // IronBarcode automatically calculates the check digit if only 7 digits are provided. string upceValue = "0123456"; // Create UPC-E GeneratedBarcode barcode = BarcodeWriter.CreateBarcode(upceValue, BarcodeWriterEncoding.UPCE); // Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode(); // Save as a JPG file barcode.SaveAsJpeg("upce.jpg"); Imports IronBarCode ' Valid Input:8 digits or less, which the last digit is a check digit calculated from the first 7 digits. ' IronBarcode automatically calculates the check digit if only 7 digits are provided. Dim upceValue As String = "0123456" ' Create UPC-E Dim barcode As GeneratedBarcode = BarcodeWriter.CreateBarcode(upceValue, BarcodeWriterEncoding.UPCE) ' Stamp barcode value below the barcode barcode.AddBarcodeValueTextBelowBarcode() ' Save as a JPG file barcode.SaveAsJpeg("upce.jpg") $vbLabelText $csharpLabel UPC-E 輸出是什麼樣子? 如何修正 UPC-E 長度錯誤? 如果數字位數超過 8,IronBarcode 會產生錯誤。 <! -- --> <!--說明:螢幕截圖或圖表 --> 有哪些不同的 1D BarCode 類型? 請輸入您的姓名 格式 常見用法 限制與陷阱 編碼 128 字母數字支援完整的 ASCII 128。長度可變。高密度。 內部物流、運送標籤、資產追蹤、ID 卡。 No Unicode:無法在不破壞掃瞄器相容性的情況下,對特殊字符(如中文或表情符號)進行本機編碼。 印表機品質:要求高解析度;低 DPI 熱感列印可能會導致可讀性問題。 GS1-128譯文 結構化字母數字Code 128 含前導 FNC1 + 應用程式識別碼 (例如:(01))。 全球供應鏈(Walmart/Amazon)、棧板標籤、EDI。 缺少 FNC1:必須以隱形 FNC1 字元開頭,否則掃描器會將其視為原始文字讀取。 括號:請勿在 AI 周圍編碼 () ;括號僅供人類閱讀。 程式碼 39 字母數字(限制)大寫字母 A-Z、0-9 和 -.$ / + % 空格。 汽車 (AIAG)、國防 (LOGMARS)、傳統工業 ID。 No Lowercase: 如果輸入"a",標準模式會失敗。延伸模式支援,但需要特定的掃描器設定。 低密度:可產生非常寬的 BarCode,不適合小型標籤。 編碼 93 Alphanumeric 與 Code 39 相似,但密度更高。 電子產品 (PCB)、加拿大郵政及內部製造。 校驗碼:需要兩個必須的校驗碼(C 和 K)。請勿手動計算,讓函式庫來完成。 掃描器支援:通常在掃描器上預設停用,以防止與 Code 39 衝突。 Codabar 數字 + 符號0-9 和 - $ : /.+.開始/停止:A、B、C、D。 血庫、圖書館、FedEx Airbills(傳統)。 Short Reads: 容易發生掃描器讀取部分代碼的錯誤(例如,從"12345"讀出"123")。 無字母:無法編碼資料字母,只能以 A-D 作為分隔符。 GS1 DataBar Numeric (14 Digits) 僅能編碼 GTIN-14。極為精簡。 鬆散的農產品 (水果貼紙)、小型化妝品和保健品小瓶。 無屬性:標準的 Omnidirectional 版本無法儲存 Expiry 或 Batch 資料 (需要 Expanded 版本)。 嚴格輸入:必須正好是 14 位數。 EAN-13。 Numeric (13 Digits)Country + Mfg + Product + Check Digit。 全球零售銷售點(超市)。 授權:需要付費的 GS1 公司前綴。 限制性前綴:前綴 200-299 僅供店內使用,在全球供應鏈中無效。 EAN-8 Numeric (8 Digits)7 Data + 1 Check Digit。 微小的零售包裝(口香糖、鉛筆)。 可用性:很難取得;GS1 只會在您的產品對 EAN-13 而言體積太小時,才會發行這些產品。 輸入長度:必須正好是 7 或 8 位數。 智慧型郵件 數字(20、25、29、31 位)高度調變(4 態)條形。 USPS 郵件分類與自動化。 Strict Lengths: 輸入內容必須完全符合 USPS 欄位 (BarCode ID、STID、MID、Serial、Zip)。 STID "234":請勿在生產中使用此示例 ID;它可能會導致郵件被拒收或折扣丟失。 MSI(Plessey) 僅限數字變數長度。 零售貨架標籤、倉儲箱。 校驗和混淆:支援 Mod 10、Mod 11、Mod 1010 等。您必須清楚知道您的掃描器所期望的是哪一個。 可靠性:與現代代碼相比,讀取率較差。 UPC-A 數(12 位) 11 位元資料 + 1 位元校驗位。 北美零售銷售點。 區域:主要是美國/加拿大。全球賣家應使用 EAN-13。 前導零:技術上,EAN-13 以 0 開頭。 UPC-E 數字 (6 位數)壓縮格式。 美國/加拿大的小型零售包裝(汽水罐)。 壓縮規則:您不能隨便"轉換"任何 UPC-A。您的號碼必須有特定的零模式才能壓縮。 數字系統:僅支援數字系統 0 或 1。 常見問題解答 可以產生哪些類型的 1D BarCode? IronBarcode 可以生成所有主要的一維條碼格式,包括 Code 128、GS1-128、Code 39、Code 93、EAN-13、EAN-8、UPC-A、UPC-E、Intelligent Mail、MSI、Codabar 和 DataBar。每種格式都適用於不同的應用 - Code 128 適用於貨運標籤,EAN-8 適用於小型產品,而 Intelligent Mail BarCode 則適用於郵政服務。 如何在 C# 中建立基本的 1D BarCode? 要使用 IronBarcode 創建一維條碼,請使用 BarcodeWriter.CreateBarcode() 方法與您的資料字串,並使用 BarcodeEncoding 枚舉來指定條碼類型。例如GeneratedBarcode barcode = BarcodeWriter.CreateBarcode("HELLO-WORLD-123", BarcodeEncoding.Code128); 儲存 BarCode 支援哪些輸出格式? IronBarcode 支持以多种格式保存生成的条形码,包括 JPEG、PNG 和 PDF。您可以使用SaveAsJpeg()、SaveAsPng()或其他SaveAs方法將條碼匯出為所需格式。 我可以自訂產生的 BarCode 大小和外觀嗎? 是的,IronBarcode 允許您使用 ResizeTo() 方法自定義條碼尺寸。您還可以使用字體大小和邊距應用可選的樣式,以確保條碼符合您的特定要求。 庫是否包含條碼格式的自動驗證? IronBarcode 包含所有支援條碼格式的自動驗證和符合性檢查。這可確保生成的條碼符合行業標準,並可被標準條碼閱讀器掃描。 為何要使用線性條碼而非 2D 條碼? 線性 BarCode 仍然是業界標準,因為它們快速、可靠,而且幾乎適用於任何掃描器。由於它們不需要複雜的圖像處理,IronBarcode 的線性條碼在零售結帳線和輸送帶等高速環境中表現出色。 Curtis Chau 立即與工程團隊聊天 技術撰稿人 Curtis Chau 擁有電腦科學學士學位(卡爾頓大學),專長於前端開發,精通 Node.js、TypeScript、JavaScript 和 React。Curtis 對製作直覺且美觀的使用者介面充滿熱情,他喜歡使用現代化的架構,並製作結構良好且視覺上吸引人的手冊。除了開發之外,Curtis 對物聯網 (IoT) 也有濃厚的興趣,他喜歡探索整合硬體與軟體的創新方式。在空閒時間,他喜歡玩遊戲和建立 Discord bots,將他對技術的熱愛與創意結合。 準備好開始了嗎? Nuget 下載 2,070,733 | 版本: 2026.2 剛剛發布 免費 NuGet 下載 總下載量:2,070,733 查看許可證