跳過到頁腳內容
與其他組件的比較

IronBarcode和Aspose.Barcode之間的比較

條碼是一種機器可讀的資料視覺化表示形式。 條碼最初是透過改變平行線的長度和間距來表達資料的。 這些線性或一維(1D)條碼可以使用稱為條碼閱讀器的專用光學掃描器進行掃描,條碼閱讀器有多種類型。後來,人們開發了使用矩形、點、六邊形和其他圖案的二維(2D)條碼,並稱之為矩陣碼,儘管它們不使用條形。 專用的二維光學掃描器有多種配置,可以讀取二維條碼。 連接到微型電腦的數位相機可以拍攝條碼的影像,同時運行掃描二維條碼的軟體——它透過分析影像來分解和解碼條碼。 使用專用應用程式軟體,內建相機的行動裝置(例如智慧型手機)可以充當後一種二維條碼掃描器。

本文將對兩個常用的條碼庫進行比較:

Aspose.Barcode

  • IronBarcode

這兩個庫都可用於產生和識別條碼。 支援所有 .NET 框架,並且可以輕鬆保存條碼圖像。

特點

Aspose.Barcode

Aspose.BarCode for .NET 是一款功能強大的工具,可讓您從各種圖片來源以任何角度建立和識別一維和二維條碼。 條碼建立和掃描功能可以由開發人員輕鬆地添加到 .NET 應用程式中。 它還允許將創建的條碼匯出為多種高品質圖片格式,並提供 API 以創建新條碼和從各種角度識別舊條碼。 支援超過 60 種不同的 1D、2D 和郵政條碼符號系統。

Aspose.BarCode for .NET 可讓您變更所建立條碼的背景顏色、條形顏色、旋轉角度、x 尺寸、影像品質、解析度、標題、大小等。 該 API 還支援各種識別和成像功能,以及各種符號體系。

  • Aspose 允許我們僅使用幾行程式碼即可產生和識別 40 多種條碼符號。
  • 可以從任意角度讀取條碼。
  • 輕鬆將條碼標籤列印到實體印表機或虛擬印表機。 支援校驗和及條碼補充資料。 Code128編碼得到了改進。
  • 設定條碼掃描的影像區域。
  • 建立與裝置解析度相關的影像。
  • 辨識格式與影像:JPEG、TIFF、PNG、BMP、GIF、EXIF 將條碼標籤儲存為圖片:EMF、SVG 平台獨立性、2D 和郵政條碼。

IronBarcode。

IronBarcode for .NET 允許程式設計師在 .NET 應用程式和網站內讀取和寫入條碼和二維碼。 IronBarcode 只需要一行程式碼即可讀取或寫入條碼。 使用 .NET 條碼庫可以讀取和寫入大多數條碼和二維碼標準。 Code 39/93/128、UPC A/E、EAN 8/13、ITF、RSS 14 / Expanded、Databar、CodaBar、Aztec、Data Matrix、MaxiCode、PDF417、MSI、Plessey、USPS 和 QR 是一些最常見的條碼。 條碼結果資料包含類型、文字、二進位資料、頁面和圖片檔案。 IronBarcode 的 API 功能如下:

IronBarcode 可讀取和寫入大多數條碼類型和二維碼標準,包括 UPC A/E、EAN 8/13、Code 39/93/128、ITF、MSI、RSS 14/Expanded、Databar、CodaBar、QR、Styled QR、Data Matrix、MaxiC、PDF417, 417417 月。 結果提供的條碼資料、類型、頁碼、文字和條碼圖片非常適合歸檔或索引系統。

  • 影像預處理可提高讀取速度和準確性 — IronBarcode 會自動預處理條碼圖片,以提高讀取速度和準確性。 它可以讀取掃描影像或即時視訊幀,並能校正旋轉、雜訊、失真和傾斜。 批次伺服器應用程式可以利用多個核心和執行緒。 自動在單頁和多頁文件中尋找一個或多個條碼。 無需使用複雜的 API,即可搜尋特定條碼類型或文件位置。
  • 專為 .NET 專案設計—只需幾行程式碼即可在幾分鐘內啟動並運行。 專為 .NET Framework 構建,是一個沒有依賴項的單一 DLL; 支援 32 位元和 64 位,可用於任何 .NET 和 .NET Core 語言。 支援行動裝置和桌面設備,可在網頁、雲端、桌面和控制台應用程式中使用。
  • 為各種文件格式建立條碼和二維碼 — 以各種文件和流格式(包括 PDF、JPG、TIFF、GIF、BMP、PNG 和 HTML)儲存和列印到文件或流。 顏色、品質、旋轉角度、大小和文字都可以更改。

1. 建立新項目

開啟 Visual Studio,前往檔案選單,選擇"新建專案",然後選擇控制台應用程式/Windows 窗體/WPF 應用程式。 條碼也可用於各種類型的應用。 您也可以使用 Webform/MVC/MVC Core 等應用程式。

Aspose Barcode Generator Alternative 1 related to 1. 建立新項目

在適當的文字方塊中輸入專案名稱並選擇檔案路徑。 然後,點擊建立按鈕並選擇所需的 .NET 框架。 現在專案將為所選應用程式生成結構,如果您選擇了控制台應用程序,它將打開 program.cs 文件,您可以在其中輸入代碼並建立/運行應用程式。

Aspose Barcode Generator Alternative 1 related to 1. 建立新項目

2. 安裝條碼庫

2.1 使用 IronBarcode

IronBarcode 庫可以透過四種方式下載和安裝。

這些工具包括

  • 使用 Visual Studio
  • 使用 Visual Studio 命令列
  • 直接從 NuGet 網站下載
  • 直接從 IronBarcode 網站下載

2.1.1 使用 Visual Studio

Visual Studio 提供了 NuGet 套件管理器選項,可以直接將套件安裝到解決方案中。 下面的截圖顯示了如何打開 NuGet Package Manager。

Aspose Barcode Generator Alternative 1 related to 2.1.1 使用 Visual Studio

它提供了一個搜尋框,用於顯示 NuGet 網站上的套件清單。在套件管理器中,我們需要搜尋關鍵字"Barcode",如下面的螢幕截圖所示:

Aspose Barcode Generator Alternative 4 related to 2.1.1 使用 Visual Studio

從上圖中,我們可以得到相關的搜尋結果清單。 我們需要選擇所需的選項,將套件安裝至解決方案。

2.1.2 使用 Visual Studio 命令列

在 Visual Studio 中,前往"工具"->"NuGet 套件管理器"->"套件管理器控制台"。

在控制台標籤中輸入以下命令:

Install-Package BarCode

該套件現在會下載/安裝到目前的專案中,並可立即使用。

2.1.3 從 NuGet 網站直接下載

第三種方法是直接從網站下載軟體包。

  • 導航至NuGet 鏈接
  • 請從右側功能表中選擇下載套件選項。
  • 雙擊下載的套件。 它會自動安裝。
  • 接下來,重新載入解決方案並開始在專案中使用。

2.1.4 從 IronBarcode 網站直接下載

點擊此處鏈接,直接從網站下載最新軟體包。下載完成後,請按照以下步驟將軟體包新增至專案。

  • 在解決方案視窗中右擊專案。 接下來,選擇參考資料選項,然後瀏覽下載的參考資料的位置。
  • 接下來,按一下確定以新增參考。

2.2 使用 Aspose.BarCode

Aspose.BarCode 函式庫可以透過四種方式下載和安裝。

這些工具包括

  • 使用 Visual Studio
  • 使用 Visual Studio 命令列
  • 直接從 NuGet 網站下載
  • 直接從 Aspose 網站下載

2.2.1 使用 Visual Studio

這種方法與上面描述的 IronBarcode 方法類似。 我們唯一需要更改的就是搜尋條件,如下圖所示。

Aspose Barcode Generator Alternative 4 related to 2.2.1 使用 Visual Studio

選擇第一個選項,即可下載 Aspose.Barcode 庫。

2.2.2 使用 Visual Studio 命令列

在 Visual Studio 中,前往"工具">"NuGet 套件管理員">"套件管理員控制台"。

在軟體包管理器控制台標籤中輸入以下代碼。

Install-Package Aspose.BarCode

該套件現在會下載/安裝到目前的專案中,並可立即使用。

2.2.3 從 NuGet 網站直接下載

第三種方法是直接從網站下載軟體包。

點擊這裡,即可跳到 NuGet 網站下載軟體包。

2.2.4 從 Aspose 網站直接下載

點擊此鏈接,即可跳到軟體包版本列表,我們可以從中選擇所需的版本進行下載。 下載完成後,請依照下列步驟將套件新增至專案中。

  • 在解決方案視窗中右擊專案。 接下來,選擇參考資料選項,然後瀏覽下載的參考資料的位置。
  • 接下來,按一下確定以新增參考。

3. 條碼生成

使用 IronBarcode 和 Aspose.Barcode 可以輕鬆產生條碼。 讓我們透過一個例子來看一下。

3.1 使用 IronBarcode

IronBarcode 可用於建立條碼標籤,並可將標籤儲存為多種影像格式。 我們也可以指定需要產生的條碼類型。 以下是條碼產生程式碼片段:

using IronBarCode;

// Create a barcode using IronBarcode
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);

// Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");

// Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg");
using IronBarCode;

// Create a barcode using IronBarcode
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);

// Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");

// Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg");
Imports IronBarCode

' Create a barcode using IronBarcode
Private MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128)

' Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456")

' Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg")
$vbLabelText   $csharpLabel

BarcodeWriter.CreateBarcode是 IronBarcode 函式庫中的一個方法。 我們需要向CreateBarcode函數傳遞兩個參數:要編碼的文字和要產生的條碼類型。 呼叫此方法後,它會傳回一個條碼對象,該對象可用於設定各種屬性,例如添加註釋文字和以不同格式儲存圖像。

// Create a QR code with a logo image
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);

// Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
// Create a QR code with a logo image
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);

// Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);

// Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
' Create a QR code with a logo image
Dim QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500)

' Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)

' Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg")
$vbLabelText   $csharpLabel

以上範例示範如何使用 IronBarcode 產生帶有標誌影像的二維碼。 CreateQrCodeWithLogo函數可讓我們建立具有嵌入式標誌的二維碼,我們可以使用ChangeBarCodeColor方法來變更條碼的顏色。

3.2 使用 Aspose.Barcode

Aspose.BarCode 可用於產生條碼,我們可以使用以下程式碼片段產生不同類型的條碼:

using Aspose.BarCode.Generation;

// Create a BarcodeGenerator object and specify the barcode type and text
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "123456");

// Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg);
using Aspose.BarCode.Generation;

// Create a BarcodeGenerator object and specify the barcode type and text
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "123456");

// Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg);
Imports Aspose.BarCode.Generation

' Create a BarcodeGenerator object and specify the barcode type and text
Private generator As New BarcodeGenerator(EncodeTypes.Code128, "123456")

' Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg)
$vbLabelText   $csharpLabel

上述程式碼使用 Aspose.Barcode 中的BarcodeGenerator建立條碼。 我們透過建構函數指定條碼類型和文字。 Save方法允許我們將產生的條碼儲存為所需的影像格式,例如 JPEG。

Aspose.BarCode 也支援使用Parameters.Barcode.XDimension.Millimeters屬性來指定線條高度和寬度,從而自訂條碼的高度和寬度。

結果:

Aspose Barcode Generator Alternative 8 related to 3.2 使用 Aspose.Barcode

上圖是這些庫的效能比較。 時間以毫秒為單位計算。

4. 辨識條碼

IronBarcode 和 Aspose.Barcodes 使我們能夠識別不同圖像格式的條碼及其所屬類型。 讓我們詳細看一下。

4.1 使用 IronBarcode

IronBarcode 可協助讀取不同影像格式的條碼,並可透過三種方式定義:字串、串流或影像(例如 JPEG、TIFF、點陣圖等)。以下範例示範如何使用字串方法從圖像中讀取條碼。

using IronBarCode;

// Read a barcode from an image file
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");

if (QRResult != null)
{
    // Output the barcode value and type
    Console.WriteLine(QRResult.Value);
    Console.WriteLine(QRResult.BarcodeType);
}
using IronBarCode;

// Read a barcode from an image file
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");

if (QRResult != null)
{
    // Output the barcode value and type
    Console.WriteLine(QRResult.Value);
    Console.WriteLine(QRResult.BarcodeType);
}
Imports IronBarCode

' Read a barcode from an image file
Private QRResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg")

If QRResult IsNot Nothing Then
	' Output the barcode value and type
	Console.WriteLine(QRResult.Value)
	Console.WriteLine(QRResult.BarcodeType)
End If
$vbLabelText   $csharpLabel

上述程式碼片段使用 IronBarcode 的BarcodeReader從影像檔案讀取條碼。 QuicklyReadOneBarcode 方法從指定的圖像中讀取條碼,並將其轉換為BarcodeResult對象,該物件包含Value (編碼後的文字QuicklyReadOneBarcodeBarcodeType (識別出的條碼類型)等屬性。

4.2 使用 Aspose.Barcode

在 Aspose.BarCode for .NET 中,條碼辨識的資料來源可以定義為三種形式:影像檔案、資料流或點陣圖。以下詳細介紹如何從 JPEG 格式的檔案中讀取條碼。

using Aspose.BarCode.BarCodeRecognition;

// Read a barcode using Aspose.BarCode
using (BarCodeReader reader = new BarCodeReader(@"MyBarCode.jpg"))
{
    // Iterate through recognized barcodes
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        // Output the barcode type and text
        Console.WriteLine("Type: " + result.CodeType);
        Console.WriteLine("CodeText: " + result.CodeText);
    }
}
using Aspose.BarCode.BarCodeRecognition;

// Read a barcode using Aspose.BarCode
using (BarCodeReader reader = new BarCodeReader(@"MyBarCode.jpg"))
{
    // Iterate through recognized barcodes
    foreach (BarCodeResult result in reader.ReadBarCodes())
    {
        // Output the barcode type and text
        Console.WriteLine("Type: " + result.CodeType);
        Console.WriteLine("CodeText: " + result.CodeText);
    }
}
Imports Aspose.BarCode.BarCodeRecognition

' Read a barcode using Aspose.BarCode
Using reader As New BarCodeReader("MyBarCode.jpg")
	' Iterate through recognized barcodes
	For Each result As BarCodeResult In reader.ReadBarCodes()
		' Output the barcode type and text
		Console.WriteLine("Type: " & result.CodeType)
		Console.WriteLine("CodeText: " & result.CodeText)
	Next result
End Using
$vbLabelText   $csharpLabel

以上範例展示如何使用 Aspose.BarCode 讀取條碼。 BarCodeReader類別用於使用路徑作為參數讀取條碼影像。 然後ReadBarCodes方法從圖像中獲取所有識別出的條碼,並使用foreach循環存取每個條碼結果,提供條碼類型和其中編碼的文字。

5.結論

IronBarcode 是最強大的條碼產生和識別庫之一。 它也是產生和識別條碼速度最快的庫之一。 該庫受多種作業系統支援。 它支援多種條碼格式,而且創建起來也很容易。 使用者可以更改顏色、行高、行寬、條碼文字等。許可詳情請點擊此處查看。

Aspose.BarCode 也是一個功能強大的函式庫,可用於產生和讀取不同影像格式的條碼。 我們可以使用各種圖像格式進行讀取和創建。 Aspose 還提供了自訂條碼外觀的選項,例如高度、寬度、條碼文字等。許可詳情請點擊此處查看。

IronBarcode 比 Aspose.Barcode 有幾個優勢。 在比較條碼識別和產生處理時間時,IronBarcode 的速度更快。 IronBarcode 還具有多種特性,不僅可以讀取不同影像格式的條碼,還可以讀取 PDF 文件中的條碼。 使用者可以在條碼和二維碼中添加圖像,這是許多庫所不具備的功能。

請注意Aspose 是其各自擁有者的註冊商標。 本網站與 Aspose 無任何關聯、背書或贊助。 所有產品名稱、標誌和品牌均為其各自擁有者的財產。 比較資料僅供參考,並反映撰寫時的公開資訊。

常見問題解答

Aspose.BarCode 和 IronBarcode 之間有哪些差異?

Aspose.BarCode for .NET 支援超過 60 種條碼符號,並允許進行廣泛的客製化。IronBarcode 以其速度和簡易性著稱,提供從 PDF 讀取條碼和自動影像預處理以提高準確性等功能。

如何使用 .NET 函式庫在 C# 中產生 BarCode?

透過呼叫 BarcodeWriter.CreateBarcode 方法,您可以使用 IronBarcode 在 C# 中產生條碼,此方法允許您指定資料和條碼類型。條碼可以多種格式保存,包括 JPEG、PNG 和 PDF。

是否可以使用 .NET 函式庫從 PDF 讀取 BarCode?

是的,IronBarcode 提供從 PDF 讀取條碼的功能,在處理各種格式的條碼辨識時提供彈性。

如何為 .NET 專案安裝 BarCode 程式庫?

您可以通過 Visual Studio 中的 NuGet Package Manager、使用 Visual Studio Command-Line 或直接從 NuGet 或 IronBarcode 網站下載,在 .NET 專案中安裝 IronBarcode。

使用 IronBarcode 生成条码有哪些好处?

IronBarcode 提供快速的處理時間,支援多種條碼標準,並包含自動影像預處理和在條碼中嵌入影像等進階功能。

我可以使用 .NET 函式庫自訂 BarCode 的外觀嗎?

是的,Aspose.Barcode 和 IronBarcode 都允許自訂條碼外觀,包括調整顏色、大小和內嵌文字。

使用 .NET 函式庫可以以哪些影像格式儲存 BarCode?

IronBarcode 可讓您以 JPEG、TIFF、PNG、BMP 和 GIF 等多種影像格式,以及 PDF 和 HTML 格式儲存條碼。

哪些平台與 .NET BarCode 程式庫相容?

IronBarcode 支援 32 位元和 64 位元的 .NET 和 .NET Core Framework,可在行動和桌上型裝置的網頁、雲端、桌面和主控台應用程式中使用。

Jordi Bardia
軟體工程師
Jordi 在 Python、C# 和 C++ 上最得心應手,當他不在 Iron Software 展現技術時,便在做遊戲編程。在分担产品测测试,产品开发和研究的责任时,Jordi 为持续的产品改进增值。他说这种多样化的经验使他受到挑战并保持参与, 而这也是他与 Iron Software 中工作一大乐趣。Jordi 在佛罗里达州迈阿密长大,曾在佛罗里达大学学习计算机科学和统计学。