GrapeCity Barcode 與 IronBarcode:C# 條碼庫對比
ComponentOne 的條碼控制項可在 Windows Forms 應用程式內產生條碼。 它在這方面做得很好——API 簡潔明了,輸出品質可靠,並且可以自然地與 WinForms 設計器整合。 但它的作用範圍很窄。 它無法讀取條碼。 它無法在 Windows 系統之外運作。 而且它不是一個獨立產品——它是 ComponentOne Studio Enterprise 的一部分,該訂閱價格約為 1,473 美元/開發人員/年,其中包括 100 多個適用於 WinForms、WPF、Blazor 和 ASP.NET 的 UI 控制項。 如果您正在評估 .NET 專案的條碼選項,並且在比較清單中發現了 ComponentOne,那麼本文將介紹該範圍在實務上意味著什麼。
了解 C1 條碼
C1BarCode 是一個 WinForms 視覺化控制項。 產生工作流程建立一個實例,設定屬性,並呼叫 GetImage() 來檢索 System.Drawing.Image:
// ComponentOne C1BarCode
using C1.Win.C1BarCode;
using System.Drawing;
// License must be set before first use
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.Code128;
barcode.Text = "ITEM-12345";
barcode.BarHeight = 100;
barcode.ModuleSize = 2;
barcode.ShowText = true;
barcode.CaptionPosition = CaptionPosition.Below;
using var image = barcode.GetImage();
image.Save("barcode.png", System.Drawing.Imaging.ImageFormat.Png);
// ComponentOne C1BarCode
using C1.Win.C1BarCode;
using System.Drawing;
// License must be set before first use
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.Code128;
barcode.Text = "ITEM-12345";
barcode.BarHeight = 100;
barcode.ModuleSize = 2;
barcode.ShowText = true;
barcode.CaptionPosition = CaptionPosition.Below;
using var image = barcode.GetImage();
image.Save("barcode.png", System.Drawing.Imaging.ImageFormat.Png);
Imports C1.Win.C1BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
' License must be set before first use
C1.C1License.Key = "YOUR-COMPONENTONE-KEY"
Dim barcode As New C1BarCode()
barcode.CodeType = CodeType.Code128
barcode.Text = "ITEM-12345"
barcode.BarHeight = 100
barcode.ModuleSize = 2
barcode.ShowText = True
barcode.CaptionPosition = CaptionPosition.Below
Using image As Image = barcode.GetImage()
image.Save("barcode.png", ImageFormat.Png)
End Using
WinForms 開發人員對屬性設定器 API 並不陌生——它直接對應到設計器介面。 CodeType、BarHeight、ModuleSize、ShowText 和 CaptionPosition 都是設計器可見的屬性,在程式碼中運作方式相同。
C1BarCode 支援主流的一維和二維條碼格式:Code 39、Code 128、EAN-8、EAN-13、UPC-A、UPC-E、ITF、QR Code 和 PDF417 等。 它涵蓋了 WinForms 生成中的常見用例。
無讀取 API
這並非可以透過配置選項來彌補的缺陷。 沒有 C1BarCodeReader 類。 Decode() 方法在 C1BarCode 上不存在。 ComponentOne 的條碼控制在設計上僅用於產生條碼。
如果您的應用程式需要掃描上傳圖像中的條碼、驗證列印標籤、處理帶有嵌入式程式碼的文檔,或從 Web API 中的二維碼提取資料——C1BarCode 都無法實現這些功能。 你需要一個單獨的庫來進行讀取,這就引出了一個問題:既然獨立的條碼庫可以同時滿足這兩個操作,為什麼還要為包含 100 多個控制功能的企業套件中的一個僅用於生成條碼的組件付費呢?
對於設計用於列印輸出的 WinForms 條碼控制項來說,缺少讀取 API 並不罕見。 當需求增加時,就會成為一個決策點-而條碼需求幾乎總是會增加。
僅限 Windows 限制
C1BarCode 需要針對 Windows 的特定目標框架設定:
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
net8.0-windows 目標框架別名和 UseWindowsForms 不是可選的首選項。 C1.Win.C1BarCode 依賴 System.Windows.Forms 類型 — UserControl、PaintEventArgs、Graphics — 這些類型僅存在於 Windows 上。 移除 net8.0-windows 會導致建置失敗。
相較之下,IronBarcode 的目標平台是 net8.0(或任何受支援的 TFM):
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
這在幾個實際場景中都很重要:
- Azure App Service on Linux:新 App Service 部署的預設方案。 無法定位到
net8.0-windows。 - Docker 容器: Linux 容器是標準。 Windows 容器體積更大、成本更高,並且在許多雲端層級中不可用。
- ASP.NET Core Web API:只能部署到 Windows 的條碼產生端點是一個部署限制,團隊最終需要將其移除。
- Azure Functions:消耗計劃在 Linux 上執行。 目標為
net8.0-windows的條碼產生函數無法部署到消費計畫。 - macOS 開發: macOS 上的開發者無法在本地運行
net8.0-windows項目,即使是測試生成邏輯也不行。
如果你的應用程式是WinForms桌面工具,而且只會在Windows上運行,那麼平台限制就不是問題。 一旦部署要求包含任何 Linux 或雲端環境,問題就會出現。
套件捆綁
C1BarCode 不是以獨立 NuGet 套件的形式提供的。 它是 ComponentOne Studio Enterprise 的一部分,其中包括適用於 WinForms、WPF、Blazor 和 ASP.NET 的完整 ComponentOne 控制項套件。 ComponentOne Studio Enterprise 的定價約為每位開發者每年 1,473 美元(訂閱)。
此套件包含 100 多個元件:網格、圖表、排程程式、輸入控制項、報表設計器、地圖控制項、儀表等等。 如果您正在建立一個資料密集型的 WinForms 應用程序,並且需要很多這樣的控件,那麼套件定價可能會更划算。 如果您需要產生條碼,並且因為在搜尋結果中看到了 ComponentOne 而找到了它,那麼您購買的是一個大型企業級 UI 套件,而它主要只是為了一個控制項。
沒有獨立的 C1BarCode 軟體包。 dotnet add package C1.Win.C1BarCode 不存在 — 該軟體包是 C1.Win.C1BarCode,屬於 GrapeCity.Documents 授權或 ComponentOne Studio 安裝程式的一部分。 對於想要條碼功能但不需要完整套件的開發者來說,沒有部分購買選項。
IronBarcode 的定價結構有所不同:它是一個獨立的條碼庫,永久許可起價為 749 美元(適用於單一開發人員)。 沒有網格控件,沒有圖表庫,沒有報表設計器——只有您正在尋找的條碼功能。
QR 圖碼定制
這兩個庫都支援生成二維碼,並提供自訂選項。 API風格差異顯著。
ComponentOne 屬性設定器方法:
// ComponentOne — QR code with error correction and color
using C1.Win.C1BarCode;
using System.Drawing;
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.QRCode;
barcode.Text = "https://example.com/product/4821";
barcode.QRCodeVersion = QRCodeVersion.Version5;
barcode.QRCodeErrorCorrectionLevel = QRCodeErrorCorrectionLevel.High;
barcode.QRCodeModel = QRCodeModel.Model2;
barcode.ForeColor = Color.DarkBlue;
barcode.BackColor = Color.White;
barcode.ModuleSize = 4;
using var image = barcode.GetImage();
image.Save("product-qr.png", System.Drawing.Imaging.ImageFormat.Png);
// ComponentOne — QR code with error correction and color
using C1.Win.C1BarCode;
using System.Drawing;
C1.C1License.Key = "YOUR-COMPONENTONE-KEY";
var barcode = new C1BarCode();
barcode.CodeType = CodeType.QRCode;
barcode.Text = "https://example.com/product/4821";
barcode.QRCodeVersion = QRCodeVersion.Version5;
barcode.QRCodeErrorCorrectionLevel = QRCodeErrorCorrectionLevel.High;
barcode.QRCodeModel = QRCodeModel.Model2;
barcode.ForeColor = Color.DarkBlue;
barcode.BackColor = Color.White;
barcode.ModuleSize = 4;
using var image = barcode.GetImage();
image.Save("product-qr.png", System.Drawing.Imaging.ImageFormat.Png);
Imports C1.Win.C1BarCode
Imports System.Drawing
Imports System.Drawing.Imaging
C1.C1License.Key = "YOUR-COMPONENTONE-KEY"
Dim barcode As New C1BarCode()
barcode.CodeType = CodeType.QRCode
barcode.Text = "https://example.com/product/4821"
barcode.QRCodeVersion = QRCodeVersion.Version5
barcode.QRCodeErrorCorrectionLevel = QRCodeErrorCorrectionLevel.High
barcode.QRCodeModel = QRCodeModel.Model2
barcode.ForeColor = Color.DarkBlue
barcode.BackColor = Color.White
barcode.ModuleSize = 4
Using image As Image = barcode.GetImage()
image.Save("product-qr.png", ImageFormat.Png)
End Using
IronBarcode 流暢鏈:
//IronBarcode— QR code with error correction and color
// NuGet: dotnet add package IronBarcode
using IronBarCode;
using System.Drawing;
QRCodeWriter.CreateQrCode(
"https://example.com/product/4821",
300,
QRCodeWriter.QrErrorCorrectionLevel.Highest)
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("product-qr.png");
//IronBarcode— QR code with error correction and color
// NuGet: dotnet add package IronBarcode
using IronBarCode;
using System.Drawing;
QRCodeWriter.CreateQrCode(
"https://example.com/product/4821",
300,
QRCodeWriter.QrErrorCorrectionLevel.Highest)
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("product-qr.png");
Imports IronBarCode
Imports System.Drawing
QRCodeWriter.CreateQrCode( _
"https://example.com/product/4821", _
300, _
QRCodeWriter.QrErrorCorrectionLevel.Highest) _
.ChangeBarCodeColor(Color.DarkBlue) _
.SaveAsPng("product-qr.png")
ComponentOne 方法需要實例化一個 C1BarCode 對象,並在呼叫 GetImage() 之前設定多個屬性。IronBarcode的 QRCodeWriter 使用流暢的鍊式操作-每個操作都會傳回條碼對象,最後呼叫 .SaveAsPng()。 沒有需要管理的實例。
IronBarcode 也支援在二維碼中嵌入徽標,而 C1BarCode 則不支援:
// QR code with embedded brand logo
QRCodeWriter.CreateQrCode("https://example.com/track/8821", 500)
.AddBrandLogo("company-logo.png")
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("branded-qr.png");
// QR code with embedded brand logo
QRCodeWriter.CreateQrCode("https://example.com/track/8821", 500)
.AddBrandLogo("company-logo.png")
.ChangeBarCodeColor(Color.DarkBlue)
.SaveAsPng("branded-qr.png");
' QR code with embedded brand logo
QRCodeWriter.CreateQrCode("https://example.com/track/8821", 500) _
.AddBrandLogo("company-logo.png") _
.ChangeBarCodeColor(Color.DarkBlue) _
.SaveAsPng("branded-qr.png")
了解 IronBarcode
IronBarcode 是一個獨立的 .NET 條碼庫,涵蓋條碼的產生和讀取。 它透過 NuGet 安裝(dotnet add package IronBarcode),針對任何支援的 .NET TFM,沒有平台限制,並且可以在 Windows、Linux、macOS、Docker、Azure 和 AWS Lambda 上運行。
閱讀方面原生支援PDF文件:
// Read barcodes from a PDF — no image extraction needed
using IronBarCode;
var results = BarcodeReader.Read("invoice.pdf");
foreach (var barcode in results)
{
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}");
}
// Read barcodes from a PDF — no image extraction needed
using IronBarCode;
var results = BarcodeReader.Read("invoice.pdf");
foreach (var barcode in results)
{
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}");
}
Imports IronBarCode
' Read barcodes from a PDF — no image extraction needed
Dim results = BarcodeReader.Read("invoice.pdf")
For Each barcode In results
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}")
Next
對於高通量場景,BarcodeReaderOptions 控制速度與準確性之間的權衡以及多條碼檢測:
// Multi-barcode read with performance options
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
ExpectedBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode
};
var results = BarcodeReader.Read("warehouse-manifest.jpg", options);
// Multi-barcode read with performance options
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
ExpectedBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode
};
var results = BarcodeReader.Read("warehouse-manifest.jpg", options);
Imports IronBarCode
' Multi-barcode read with performance options
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True,
.ExpectedBarcodeTypes = BarcodeEncoding.Code128 Or BarcodeEncoding.QRCode
}
Dim results = BarcodeReader.Read("warehouse-manifest.jpg", options)
生成功能涵蓋標準格式,並提供一致的靜態 API:
// Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128)
.SaveAsPng("shipping-label.png");
// 二維碼生成 to byte array (for HTTP response)
byte[] qrBytes = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400)
.ToPngBinaryData();
// Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128)
.SaveAsPng("shipping-label.png");
// 二維碼生成 to byte array (for HTTP response)
byte[] qrBytes = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400)
.ToPngBinaryData();
Imports ZXing
Imports ZXing.QrCode
' Code 128 generation to file
BarcodeWriter.CreateBarcode("SHIP-20240312-7834", BarcodeEncoding.Code128) _
.SaveAsPng("shipping-label.png")
' 二維碼生成 to byte array (for HTTP response)
Dim qrBytes As Byte() = QRCodeWriter.CreateQrCode("https://example.com/order/7734", 400) _
.ToPngBinaryData()
支援的平台:Windows、Linux、macOS、Docker、Azure(應用程式服務和函數)、AWS Lambda。 支援的 .NET 版本:.NET 4.6.2 至 .NET 9。
功能比較
| 特點 | GrapeCity C1條碼 | IronBarcode |
|---|---|---|
| 條碼生成 | 是 | 是 |
| 條碼讀取 | 無 | 是 |
| 二維碼生成 | 是 | 是 |
| QR 圖碼標誌嵌入 | 無 | 是 |
| 用於閱讀的 PDF 輸入 | 不適用(無讀數) | 是的(母語) |
| .NET平台目標 | net8.0-windows 僅限 |
任何 TFM(net8.0 等) |
| 需要使用 Windows Forms。 | 是 | 無 |
| Linux/Docker部署 | 無 | 是 |
| macOS部署 | 無 | 是 |
| Azure Functions(Linux) | 無 | 是 |
| ASP.NET Core 伺服器端 | 有限(僅限 Windows 系統) | 是 |
| 獨立 NuGet 套件 | 無(僅套件) | 是 |
| 獨立定價 | 不適用 | $749 起永久 |
| 套房定價 | 約 1,473 美元/設備/年(訂閱) | 不適用 |
| 流暢產生 API | 否(屬性設定者) | 是 |
BarcodeReader.Read() |
無 | 是 |
BarcodeWriter.CreateBarcode() |
無 | 是 |
QRCodeWriter.CreateQrCode() |
無 | 是 |
| 支援的 .NET 版本 | .NET 6+(Windows) | .NET 4.6.2 至 .NET 9 |
| 永久授權選項 | 無需訂閱 | 是 |
API 對應參考。
對於從 C1BarCode 遷移到IronBarcode的團隊,以下直接對應適用:
| ComponentOne C1條碼 | IronBarcode |
|---|---|
C1.C1License.Key = "..." |
IronBarCode.License.LicenseKey = "key" |
new C1BarCode() |
靜態-無需實例 |
barcode.CodeType = CodeType.Code128 |
BarcodeEncoding.Code128(作為參數傳遞) |
barcode.Text = "data" |
BarcodeWriter.CreateBarcode() 的第一個參數 |
barcode.BarHeight = 100 |
條碼寫入器上的 .ResizeTo(width, 100) |
barcode.ModuleSize = 2 |
.ResizeTo() 控制像素尺寸 |
barcode.ForeColor = Color.DarkBlue |
.ChangeBarCodeColor(Color.DarkBlue) |
barcode.BackColor = Color.White |
.ChangeBackgroundColor(Color.White) |
barcode.GetImage() |
.SaveAsPng() / .ToPngBinaryData() |
barcode.QRCodeErrorCorrectionLevel |
QRCodeWriter.QrErrorCorrectionLevel枚舉 |
barcode.QRCodeVersion |
自動(或版本參數) |
| 無讀取 API | BarcodeReader.Read(path) |
net8.0-windows 必填 |
net8.0(或任何 TFM) |
UseWindowsForms = true 必填 |
不需要 |
當球隊切換
閱讀需求出現了。這是最常見的觸發因素。 一個團隊使用 C1BarCode 建立條碼標籤產生器,然後收到驗證掃描、處理入庫貨運單據或解碼上傳影像中的二維碼的需求。 C1BarCode 無法解決這個問題。有兩種選擇:要么添加第二個條碼讀取庫,要么用一個可以同時處理這兩種情況的庫替換 C1BarCode。
Linux 或 Docker 部署。而發佈到 Windows 桌面的 WinForms 桌面應用程式則不受此限制。 產生條碼映像的 ASP.NET Core API 確實如此——尤其是在需要在 Linux 容器中執行或部署到 Linux 上的 Azure 應用程式服務時。 net8.0-windows 目標框架立即阻止了這些部署選項。
微服務或無伺服器架構。 Azure Functions、AWS Lambda 和容器化微服務都優先考慮 Linux。無法部署到 Linux 的條碼產生服務不能稱為可行的微服務。
套件訂閱成本與需求範圍。已經付費使用 ComponentOne Studio Enterprise 並已在使用其網格、圖表和其他控制項的團隊,已經證明了訂閱的合理性。 主要或完全為了產生條碼而訂閱的團隊,正在為 100 多個他們沒有使用的控制項付費。 每位開發人員的訂閱費用會隨著團隊規模的擴大而增加。
永久授權優先。 ComponentOne Studio 僅提供訂閱服務。 沒有永久授權選項。 對於那些更喜歡擁有自己交付的軟體的團隊(特別是出於合規性或長期維護的原因),IronBarcode 的永久許可(起價為 749 美元)在結構上有所不同。
結論
C1BarCode 能夠在 WinForms 環境中乾淨俐落地產生條碼。 這正是它真正擅長的,對於只需要在 Windows 上產生標籤的 WinForms 桌面應用程式來說,它是 ComponentOne 套件中的功能性選擇。
範圍僅限於此。 不支援讀取,僅限 Windows 部署,無獨立軟體包,採用訂閱許可。 當一個專案的需求超出了在 Windows 上產生 WinForms 的範圍時——例如閱讀需求、Linux 部署目標、Web API、Docker 容器、雲端函數——C1BarCode 就無法滿足這些需求了。IronBarcode涵蓋條碼產生和讀取,可在 .NET 支援的任何平台上運行,並且可以作為獨立軟體包使用,無需訂閱包含 100 個控制項的企業套件。
常見問題解答
GrapeCity條碼是什麼?
GrapeCity Barcode 是一個 .NET 條碼庫,用於在 C# 應用程式中產生和讀取條碼。它是開發人員在為 .NET 專案選擇條碼解決方案時評估的幾個替代方案之一。
GrapeCity Barcode 和 IronBarcode 的主要差異是什麼?
IronBarcode 使用靜態、無狀態的 API,無需實例管理,而 GrapeCity Barcode 通常需要在使用前建立和設定實例。 IronBarcode 還提供原生 PDF 支援、自動格式偵測以及跨所有環境的單金鑰許可。
IronBarcode 的授權比 GrapeCity Barcode 更容易嗎?
IronBarcode 使用單一授權金鑰,同時涵蓋開發和生產部署。與將 SDK 金鑰與執行時間金鑰分開的授權系統相比,這簡化了 CI/CD 管線和 Docker 配置。
IronBarcode 是否支援 GrapeCity Barcode 支援的所有條碼格式?
IronBarcode 支援超過 30 種條碼符號體系,包括 QR 碼、Code 128、Code 39、DataMatrix、PDF417、Aztec、EAN-13、UPC-A、GS1 等等。格式自動偵測功能意味著無需明確枚舉格式。
IronBarcode是否支援原生PDF條碼讀取?
是的。 IronBarcode 可以直接從 PDF 檔案讀取條碼,使用 `BarcodeReader.Read("document.pdf")` 方法,無需單獨的 PDF 渲染庫。每頁的讀取結果包括頁碼、條碼格式、數值和置信度評分。
IronBarcode 與 GrapeCity Barcode 相比,在大量處理方面有何不同?
IronBarcode 的靜態方法是無狀態的,且天然執行緒安全,因此可以直接使用 Parallel.ForEach,而無需進行執行緒層級實例管理。所有定價層級均無吞吐量上限。
IronBarcode支援哪些.NET版本?
IronBarcode 在單一 NuGet 套件中支援 .NET Framework 4.6.2+、.NET Core 3.1 以及 .NET 5、6、7、8 和 9。平台目標包括 Windows x64/x86、Linux x64 和 macOS x64/ARM。
如何在.NET專案中安裝IronBarcode?
透過 NuGet 安裝 IronBarcode:在程式包管理器控制台中執行“Install-Package IronBarCode”,或在命令列介面中執行“dotnet add package IronBarCode”。無需其他 SDK 安裝程式或運行時檔案。
與 GrapeCity 不同,我可以在購買前評估 IronBarcode 嗎?
是的。 IronBarcode 的試用模式會傳回完整的解碼條碼值-只有產生的輸出影像才會有浮水印。您可以在購買前,用自己的文件測試讀取準確率。
GrapeCity Barcode 和 IronBarcode 的價格有什麼不同?
IronBarcode 的永久單開發者許可證起價為 749 美元,涵蓋開發和生產環境。定價詳情和大量許可選項請造訪 IronBarcode 授權頁面。無需單獨的運行時許可證。
從 GrapeCity Barcode 遷移到 IronBarcode 是否很簡單?
從 GrapeCity Barcode 遷移到 IronBarcode 主要涉及將基於實例的 API 呼叫替換為 IronBarcode 的靜態方法、移除許可相關的樣板程式碼以及更新結果屬性名稱。大多數遷移工作都是減少程式碼,而不是增加程式碼。
IronBarcode 能產生帶有 logo 的二維碼嗎?
是的。 `QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png")` 可以將品牌圖片原生嵌入二維碼中,並支援設定糾錯功能。此外,它還支援透過 `ChangeBarCodeColor()` 函數建立彩色二維碼。

