跳至頁尾內容
與其他組件的比較

在.NET開發中應該使用哪個C#條碼程式庫?

所有曾經用過Aspose.BarCode的開發者都編寫過這行程式碼的某個版本:new BarCodeReader(path, DecodeType.Code128)。 當您知道圖像中的格式時,它運作良好。 當您不知道時——當文件來自外部系統、供應商更改了標籤格式,或使用者上傳時——您要麼猜測一個解碼型別列表,要麼選用DecodeType.AllSupportedTypes,這通常比Aspose自己指導的要慢。 格式規範的要求並不是障礙,但在您的程式碼庫中的每次讀取操作中累加形成每天的摩擦。

PDF故事即是預算故事。 如果您從PDF文件中處理條形碼,Aspose.BarCode無法單獨完成此操作。 您需要Aspose.PDF for .NET先將頁面渲染成圖像。Aspose.PDF是您已經為Aspose.BarCode支付的費用之外的另一個訂閱產品。 一個工作流程需要兩個訂閱,大多數開發者將其視為一個任務。

IronBarcode自動檢測條形碼格式,直接在一個單一軟體包中讀取PDF,提供永久授權,起價$749。這個比較詳細檢查了兩個程式庫,以便您做出基於事實的選擇。

了解Aspose.BarCode

多年來,Aspose一直在為.NET、Java及其他平台構建文件處理程式庫。 Aspose.BarCode是該系列的眾多產品之一,此外還有Aspose.Words、Aspose.Cells、Aspose.PDF、Aspose.Slides及其他約十幾種產品。 對於已經為Aspose.Total付費的團隊——包含所有Aspose產品的捆綁——Aspose.BarCode不會產生額外的邊際成本。對於只需要條形碼程式庫的團隊來說,訂閱模式更難以證明其合理性。

Aspose.BarCode支持超過80種條形碼語法,這是任何商業.NET條形碼庫中最完備的格式列表之一。 這種廣度是該程式庫的最強銷售點。 API介面相應地很大,功能增加了API的冗長性。 生成基本的Code 128條形碼需要實例化Save。 讀取需要指定要搜索的解碼型別,然後迭代ReadBarCodes()返回的結果。 兩者皆正常工作——只是比它們需要的更加冗長。

Aspose.BarCode的關鍵架構特徵:

  • 格式優先的讀取模型:每次讀取操作都需要明確指定DecodeType。 後備DecodeType.AllSupportedTypes通常比針對的列表慢,因為解碼器依次遍歷所有已知的語法。
  • 基於實例的API:IDisposable。 它們應該被包裝在using塊中以釋放本機資源。
  • 沒有本地PDF支持: Aspose.BarCode不能直接打開或渲染PDF文件。 從PDF中讀取條形碼需要Aspose.PDF,這是一個單獨的訂閱產品。
  • 深層參數層次結構:定制通過generator.Parameters.Barcode.*屬性鏈處理——這是一個多層次的物件層次結構,需要記憶。
  • 訂閱授權:根據Aspose公佈的價格,每開發者和站點層級是年度訂閱; 沒有列出單獨的永久選項。
  • 基於文件的授權激活:生成部署需要一個.lic文件可以在已知路徑存取,這為Docker和Kubernetes環境增加了一步部署。

格式優先的讀取模型

Aspose.BarCode的讀取API基於呼叫者知道條形碼格式的假設:

using Aspose.BarCode.BarCodeRecognition;

var reader = new BarCodeReader("barcode.png", DecodeType.Code128);
foreach (var result in reader.ReadBarCodes())
    Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}");
using Aspose.BarCode.BarCodeRecognition;

var reader = new BarCodeReader("barcode.png", DecodeType.Code128);
foreach (var result in reader.ReadBarCodes())
    Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}");
Imports Aspose.BarCode.BarCodeRecognition

Dim reader As New BarCodeReader("barcode.png", DecodeType.Code128)
For Each result In reader.ReadBarCodes()
    Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}")
Next
$vbLabelText   $csharpLabel

當您知道格式時,這個模式是可以接受的。問題是"當您知道格式。"一個處理供應商發票的採購系統不能保證每個供應商使用相同的條形碼型別。 文件管理系統接受使用者上傳的文件無法預測掃描儀採用了什麼格式。 在這些情況下,DecodeType.AllSupportedTypes是後備,並且通常比目標解碼型別列表慢。

解碼器還必須被處理:

using var reader = new BarCodeReader("barcode.png", DecodeType.Code128);
using var reader = new BarCodeReader("barcode.png", DecodeType.Code128);
$vbLabelText   $csharpLabel

不使用using會導致資源泄露。 IDisposable,儘管不處理它的後果不那麼嚴重。 在這兩種情況下,您都在管理一個靜態工廠API會自動處理的物件的生命週期。

理解IronBarcode

IronBarcode對於讀寫都使用靜態工廠方法。 沒有實例需要構建、配置或處理。 讀取API預設為格式不可知,相同的調用適用於PNG、JPEG、TIFF或PDF作為源文件。

IronBarcode由專注於.NET開發者工具的Iron Software開發和維護。 這個程式庫的設計原則是條形碼的讀取不應該需要事先知道條形碼格式——程式庫的檢測引擎從圖像內容中確定格式。 生成過程中,流暢的方法鏈代替了其他程式庫中常見的多層參數層次結構。

IronBarcode的關鍵特性:

  • 自動格式檢測:DecodeType的等價物。
  • 靜態無狀態API:所有讀寫操作都是靜態方法。 沒有可處理的可丟棄實例,API自然而然地支持併發使用的執行緒安全。
  • 本地PDF支持:result.PageNumber
  • 流暢生成API:BarcodeWriter.CreateBarcode()返回一個可連接的物件。 定制使用方法連結而不是屬性層次結構。
  • 永久授權模型:所有級別提供一次性購買,無需年度續約。
  • 基於字串的授權激活:授權金鑰通過IronBarCode.License.LicenseKey設置,相容環境變數和CI/CD秘密管理器。

特性比較

特性 Aspose.BarCode IronBarcode
格式檢測 手動——必須指定AllSupportedTypes 自動涵蓋所有支持格式
語法數量 80+ 50+
PDF支援 無本地支持——需要單獨的Aspose.PDF授權 本地——BarcodeReader.Read("doc.pdf")內建在包中
定價模型 僅限訂閱——年級從$999/年起 永久從$749起(一次性)
永久授權 不可用 是,所有層級
API風格 基於實例,冗長的配置 靜態工廠方法,流暢的API
IDisposable需求 是——BarcodeGenerator 否——無狀態靜態方法
執行緒安全 每個執行緒需要單獨的實例 靜態API——請參閱IronBarcode文件以獲取執行緒指南

詳細特性比較

特性 Aspose.BarCode IronBarcode
生成
API風格 new BarcodeGenerator(EncodeTypes.X, "data") BarcodeWriter.CreateBarcode("data", BarcodeEncoding.X)
定制模型 generator.Parameters.Barcode.*屬性層次結構 流暢方法鏈(.ChangeBarCodeColor()
帶標誌的QR碼 生成後手動GDI+疊加 .AddBrandLogo("logo.png")內建
輸出到位元組 generator.GenerateBarCodeImage() .ToPngBinaryData()
彩色條形碼 generator.Parameters.Barcode.BarColor .ChangeBarCodeColor(Color.X)
讀取
格式規範 必需(DecodeType 不需要——自動
未知格式的後備 DecodeType.AllSupportedTypes(慢) 相同調用——不需要後備模式
性能調整 QualitySettings參數集 ReadingSpeed枚舉——三級別
可丟棄讀者 是——using var reader = new BarCodeReader(...) 否——靜態調用,無需處理物件
結果存取 迭代reader.ReadBarCodes() 返回BarcodeReader.Read()的值
條形碼值屬性 result.CodeText result.Value
格式名稱屬性 result.CodeTypeName result.Format.ToString()
PDF支持
本地PDF讀取
需要PDF Aspose.PDF(單獨訂閱) 無需額外包
結果中的頁碼 不適用 result.PageNumber
授權
授權模型 僅限訂閱,年度續訂 永久一次性購買
單個開發人員 $999/年 $749一次性
10個開發人員 $4,995/年(站点授权) $2,999一次性(專業版)
無限部署(10個開發人員) $13,986/年(站点OEM) $5,999一次性(無限)
包括PDF支持 否——單獨的Aspose.PDF訂閱
平台和部署
授權激活 .lic文件路徑 字串密鑰——環境變數
Docker部署 必須將.lic文件複製到映像中或掛載它 環境變數——不需要文件
.NET Framework 是(4.6.2+)
.NET Core / .NET 5+ 是(.NET Core 3.1+,.NET 5/6/7/8)
Windows 是(x64/x86)
Linux 是(x64)
macOS 是(x64/ARM)
Docker
Azure / AWS Lambda

生成API

生成API是兩個程式庫中在日常程式碼中最明顯的冗長差異所在。

Aspose.BarCode方法

Aspose.BarCode使用帶有Parameters層次結構進行配置。 一次簡單生成調用需要三步——實例化、保存調用和格式規範。 真正的使用通常需要導航到generator.Parameters.Barcode.*中:

using Aspose.BarCode.Generation;
using System.Drawing;

var generator = new BarcodeGenerator(EncodeTypes.Code128, "ITEM-12345");

// Common customizations require navigating a deep parameter hierarchy
generator.Parameters.Barcode.XDimension.Pixels = 2;
generator.Parameters.Barcode.BarHeight.Pixels = 100;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below;
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "Arial";
generator.Parameters.Barcode.Padding.Left.Pixels = 10;
generator.Parameters.Barcode.Padding.Right.Pixels = 10;
generator.Parameters.BackColor = Color.White;
generator.Parameters.Resolution = 300;

generator.Save("barcode.png", BarCodeImageFormat.Png);
using Aspose.BarCode.Generation;
using System.Drawing;

var generator = new BarcodeGenerator(EncodeTypes.Code128, "ITEM-12345");

// Common customizations require navigating a deep parameter hierarchy
generator.Parameters.Barcode.XDimension.Pixels = 2;
generator.Parameters.Barcode.BarHeight.Pixels = 100;
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below;
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "Arial";
generator.Parameters.Barcode.Padding.Left.Pixels = 10;
generator.Parameters.Barcode.Padding.Right.Pixels = 10;
generator.Parameters.BackColor = Color.White;
generator.Parameters.Resolution = 300;

generator.Save("barcode.png", BarCodeImageFormat.Png);
Imports Aspose.BarCode.Generation
Imports System.Drawing

Dim generator As New BarcodeGenerator(EncodeTypes.Code128, "ITEM-12345")

' Common customizations require navigating a deep parameter hierarchy
generator.Parameters.Barcode.XDimension.Pixels = 2
generator.Parameters.Barcode.BarHeight.Pixels = 100
generator.Parameters.Barcode.CodeTextParameters.Location = CodeLocation.Below
generator.Parameters.Barcode.CodeTextParameters.Font.FamilyName = "Arial"
generator.Parameters.Barcode.Padding.Left.Pixels = 10
generator.Parameters.Barcode.Padding.Right.Pixels = 10
generator.Parameters.BackColor = Color.White
generator.Parameters.Resolution = 300

generator.Save("barcode.png", BarCodeImageFormat.Png)
$vbLabelText   $csharpLabel

每次定制都需要導航到generator.Parameters.Barcode.*,這是多層次的物件層次結構。 一旦您記住了就不復雜——但仍需記憶。

IronBarcode方法

IronBarcode用流暢的方法鏈取代了參數層次結構。 預設設置生成大多數情況下正確的結果,定制被內聯表達:

using IronBarCode;

// Default settings work for most cases
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .SaveAsPng("barcode.png");

// Customization through a fluent chain
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng("barcode.png");

// Get as bytes instead of saving to disk
byte[] pngData = BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .ToPngBinaryData();
using IronBarCode;

// Default settings work for most cases
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .SaveAsPng("barcode.png");

// Customization through a fluent chain
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng("barcode.png");

// Get as bytes instead of saving to disk
byte[] pngData = BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128)
    .ToPngBinaryData();
Imports IronBarCode

' Default settings work for most cases
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128) _
    .SaveAsPng("barcode.png")

' Customization through a fluent chain
BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128) _
    .ResizeTo(400, 100) _
    .SaveAsPng("barcode.png")

' Get as bytes instead of saving to disk
Dim pngData As Byte() = BarcodeWriter.CreateBarcode("ITEM-12345", BarcodeEncoding.Code128) _
    .ToPngBinaryData()
$vbLabelText   $csharpLabel

對於QR碼,IronBarcode的QR生成API包含品牌標誌支持,無需手動圖像合成:

using IronBarCode;
using IronSoftware.Drawing;

// With brand logo — built in, no manual image overlay needed
QRCodeWriter.CreateQrCode("https://example.com", 500)
    .AddBrandLogo("logo.png")
    .SaveAsPng("qr-branded.png");

// With high error correction (recommended when using a logo)
QRCodeWriter.CreateQrCode(
    "https://example.com",
    500,
    QRCodeWriter.QrErrorCorrectionLevel.Highest)
    .AddBrandLogo("logo.png")
    .SaveAsPng("qr-branded-high-ecc.png");

// Colored QR code
QRCodeWriter.CreateQrCode("https://example.com", 300)
    .ChangeBarCodeColor(Color.DarkBlue)
    .SaveAsPng("qr-colored.png");
using IronBarCode;
using IronSoftware.Drawing;

// With brand logo — built in, no manual image overlay needed
QRCodeWriter.CreateQrCode("https://example.com", 500)
    .AddBrandLogo("logo.png")
    .SaveAsPng("qr-branded.png");

// With high error correction (recommended when using a logo)
QRCodeWriter.CreateQrCode(
    "https://example.com",
    500,
    QRCodeWriter.QrErrorCorrectionLevel.Highest)
    .AddBrandLogo("logo.png")
    .SaveAsPng("qr-branded-high-ecc.png");

// Colored QR code
QRCodeWriter.CreateQrCode("https://example.com", 300)
    .ChangeBarCodeColor(Color.DarkBlue)
    .SaveAsPng("qr-colored.png");
Imports IronBarCode
Imports IronSoftware.Drawing

' With brand logo — built in, no manual image overlay needed
QRCodeWriter.CreateQrCode("https://example.com", 500) _
    .AddBrandLogo("logo.png") _
    .SaveAsPng("qr-branded.png")

' With high error correction (recommended when using a logo)
QRCodeWriter.CreateQrCode( _
    "https://example.com", _
    500, _
    QRCodeWriter.QrErrorCorrectionLevel.Highest) _
    .AddBrandLogo("logo.png") _
    .SaveAsPng("qr-branded-high-ecc.png")

' Colored QR code
QRCodeWriter.CreateQrCode("https://example.com", 300) _
    .ChangeBarCodeColor(Color.DarkBlue) _
    .SaveAsPng("qr-colored.png")
$vbLabelText   $csharpLabel

Aspose.BarCode不提供一個調用的品牌標誌幫助工具用於QR碼; 文件所述的方法是生成條形碼圖像,然後將標誌疊加(例如使用System.Drawing.Graphics)。 IronBarcode的AddBrandLogo用一個調用處理複合,並自動設置適當的錯誤修正。

PDF條形碼讀取

對於很多團隊來說,這是最重要的比較。從PDF文件中讀取條形碼是一個常見的工作流程:輸入的發票、已保存為PDF的運貨標籤、掃描的文件存檔。

Aspose.BarCode方法

Aspose.BarCode沒有本地PDF支持。 要用Aspose從PDF中讀取條形碼,您需要使用Aspose.PDF載入PDF並渲染頁面成圖像,然後用Aspose.BarCode掃描這些渲染的圖像。 兩者都是訂閱產品。 都需要授權激活。 您正在為大多數開發者認為的單一功能支付兩項年度訂閱費用。

// Requires both Aspose.PDF (separate license) and Aspose.BarCode
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.BarCode.BarCodeRecognition;
using System.IO;

public List<string> ReadBarcodesFromPdf(string pdfPath)
{
    var barcodeValues = new List<string>();

    // Step 1: Load and render the PDF using Aspose.PDF
    var pdfDocument = new Aspose.Pdf.Document(pdfPath);
    var resolution = new Resolution(300);
    var device = new PngDevice(resolution);

    for (int pageNum = 1; pageNum <= pdfDocument.Pages.Count; pageNum++)
    {
        using var pageStream = new MemoryStream();
        device.Process(pdfDocument.Pages[pageNum], pageStream);
        pageStream.Seek(0, SeekOrigin.Begin);

        // Step 2: Scan the rendered image for barcodes using Aspose.BarCode
        using var reader = new BarCodeReader(pageStream, DecodeType.AllSupportedTypes);
        foreach (var result in reader.ReadBarCodes())
        {
            barcodeValues.Add(result.CodeText);
        }
    }

    return barcodeValues;
}
// Requires both Aspose.PDF (separate license) and Aspose.BarCode
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.BarCode.BarCodeRecognition;
using System.IO;

public List<string> ReadBarcodesFromPdf(string pdfPath)
{
    var barcodeValues = new List<string>();

    // Step 1: Load and render the PDF using Aspose.PDF
    var pdfDocument = new Aspose.Pdf.Document(pdfPath);
    var resolution = new Resolution(300);
    var device = new PngDevice(resolution);

    for (int pageNum = 1; pageNum <= pdfDocument.Pages.Count; pageNum++)
    {
        using var pageStream = new MemoryStream();
        device.Process(pdfDocument.Pages[pageNum], pageStream);
        pageStream.Seek(0, SeekOrigin.Begin);

        // Step 2: Scan the rendered image for barcodes using Aspose.BarCode
        using var reader = new BarCodeReader(pageStream, DecodeType.AllSupportedTypes);
        foreach (var result in reader.ReadBarCodes())
        {
            barcodeValues.Add(result.CodeText);
        }
    }

    return barcodeValues;
}
Imports Aspose.Pdf
Imports Aspose.Pdf.Devices
Imports Aspose.BarCode.BarCodeRecognition
Imports System.IO

Public Function ReadBarcodesFromPdf(pdfPath As String) As List(Of String)
    Dim barcodeValues As New List(Of String)()

    ' Step 1: Load and render the PDF using Aspose.PDF
    Dim pdfDocument As New Aspose.Pdf.Document(pdfPath)
    Dim resolution As New Resolution(300)
    Dim device As New PngDevice(resolution)

    For pageNum As Integer = 1 To pdfDocument.Pages.Count
        Using pageStream As New MemoryStream()
            device.Process(pdfDocument.Pages(pageNum), pageStream)
            pageStream.Seek(0, SeekOrigin.Begin)

            ' Step 2: Scan the rendered image for barcodes using Aspose.BarCode
            Using reader As New BarCodeReader(pageStream, DecodeType.AllSupportedTypes)
                For Each result In reader.ReadBarCodes()
                    barcodeValues.Add(result.CodeText)
                Next
            End Using
        End Using
    Next

    Return barcodeValues
End Function
$vbLabelText   $csharpLabel

這是兩種授權設置,來自兩個命名空間的兩種using聲明,一個渲染處理管道,記憶體流管理和巢狀迴圈。它也使用DecodeType.AllSupportedTypes,因為在圖像提取時您通常不知道條形碼採用了什麼格式。

IronBarcode方法

IronBarcode內部處理PDF解析、頁面渲染和條形碼檢測。 您使用result.PageNumber,因此您知道每個條形碼來自哪一頁。 無需第二包,無需第二授權,無需渲染程式碼。

using IronBarCode;

public List<string> ReadBarcodesFromPdf(string pdfPath)
{
    var results = BarcodeReader.Read(pdfPath);
    return results.Select(r => r.Value).ToList();
}
using IronBarCode;

public List<string> ReadBarcodesFromPdf(string pdfPath)
{
    var results = BarcodeReader.Read(pdfPath);
    return results.Select(r => r.Value).ToList();
}
Imports IronBarCode

Public Function ReadBarcodesFromPdf(pdfPath As String) As List(Of String)
    Dim results = BarcodeReader.Read(pdfPath)
    Return results.Select(Function(r) r.Value).ToList()
End Function
$vbLabelText   $csharpLabel
// With page number context
var results = BarcodeReader.Read("invoice-batch.pdf");
foreach (var barcode in results)
{
    Console.WriteLine($"Page {barcode.PageNumber}: [{barcode.Format}] {barcode.Value}");
}
// With page number context
var results = BarcodeReader.Read("invoice-batch.pdf");
foreach (var barcode in results)
{
    Console.WriteLine($"Page {barcode.PageNumber}: [{barcode.Format}] {barcode.Value}");
}
Imports System

' With page number context
Dim results = BarcodeReader.Read("invoice-batch.pdf")
For Each barcode In results
    Console.WriteLine($"Page {barcode.PageNumber}: [{barcode.Format}] {barcode.Value}")
Next
$vbLabelText   $csharpLabel

IronBarcodePDF讀取文件 涵蓋了多頁批處理和頁面範圍過濾選項。

讀取未知條形碼格式

當您不知道一個影像中包含何種條形碼格式時,兩個程式庫的處理方式不同。

Aspose.BarCode方法

DecodeType.AllSupportedTypes是Aspose對格式未知情況的解決方案。 Aspose自己的文件承認它比指定目標列表要慢,因為解碼器依次遍歷每個已知的語法。 對於高容量處理——一個倉庫每分鐘掃描數千條標籤——這個性能差異不是微不足道的。

using Aspose.BarCode.BarCodeRecognition;

using var reader = new BarCodeReader("unknown-format.png");
reader.SetBarCodeReadType(DecodeType.AllSupportedTypes);
foreach (var result in reader.ReadBarCodes())
{
    Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}");
}
using Aspose.BarCode.BarCodeRecognition;

using var reader = new BarCodeReader("unknown-format.png");
reader.SetBarCodeReadType(DecodeType.AllSupportedTypes);
foreach (var result in reader.ReadBarCodes())
{
    Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}");
}
Imports Aspose.BarCode.BarCodeRecognition

Using reader As New BarCodeReader("unknown-format.png")
    reader.SetBarCodeReadType(DecodeType.AllSupportedTypes)
    For Each result In reader.ReadBarCodes()
        Console.WriteLine($"{result.CodeTypeName}: {result.CodeText}")
    Next
End Using
$vbLabelText   $csharpLabel

IronBarcode方法

沒有基於格式認知的"慢模式"和"快模式"。 IronBarcode的檢測無論圖像中包含的是Code 128還是DataMatrix都運行著相同的算法。 如果您想在性能與準確性之間進行調整,ReadingSpeed選項可以做到這一點,而不需要格式知識:

using IronBarCode;

// The same call regardless of format — always auto-detects
var results = BarcodeReader.Read("unknown-format.png");
foreach (var result in results)
{
    Console.WriteLine($"{result.Format}: {result.Value}");
}
using IronBarCode;

// The same call regardless of format — always auto-detects
var results = BarcodeReader.Read("unknown-format.png");
foreach (var result in results)
{
    Console.WriteLine($"{result.Format}: {result.Value}");
}
Imports IronBarCode

' The same call regardless of format — always auto-detects
Dim results = BarcodeReader.Read("unknown-format.png")
For Each result In results
    Console.WriteLine($"{result.Format}: {result.Value}")
Next
$vbLabelText   $csharpLabel
using IronBarCode;

var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};

var results = BarcodeReader.Read("document.png", options);
using IronBarCode;

var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    MaxParallelThreads = 4
};

var results = BarcodeReader.Read("document.png", options);
Imports IronBarCode

Dim options As New BarcodeReaderOptions With {
    .Speed = ReadingSpeed.Balanced,
    .ExpectMultipleBarcodes = True,
    .MaxParallelThreads = 4
}

Dim results = BarcodeReader.Read("document.png", options)
$vbLabelText   $csharpLabel

ReadingSpeed.Faster優先考慮吞吐量。 ReadingSpeed.Detailed優先考慮損壞或低對比度影像上的準確性。 兩者均不需您提前知道格式。 請參見IronBarcode讀取選項以獲取完整的調整參數集。

API對映參考

Aspose.BarCode IronBarcode
new BarcodeGenerator(EncodeTypes.Code128, "data") BarcodeWriter.CreateBarcode("data", BarcodeEncoding.Code128)
generator.Save("file.png", BarCodeImageFormat.Png) .SaveAsPng("file.png")
new BarCodeReader(path, DecodeType.Code128) BarcodeReader.Read(path)
DecodeType.AllSupportedTypes(慢,徹底掃描) 自動——始終快速,對所有格式都是同樣的調用
reader.ReadBarCodes() (part of BarcodeReader.Read — returns results directly)
迭代reader.ReadBarCodes() BarcodeReader.Read的返回值
result.CodeText result.Value
result.CodeTypeName result.Format.ToString()
result.Confidence result.Confidence
Aspose.BarCode + Aspose.PDF for PDF reading BarcodeReader.Read("doc.pdf")——一個包
license.SetLicense("Aspose.BarCode.lic") IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
new Aspose.BarCode.Metered() + .SetMeteredKey() (not needed — single key covers all environments)
generator.GenerateBarCodeImage() .SaveAsPng()
QREncodeMode.Auto + QRErrorLevel.LevelH +手動標誌疊加 QRCodeWriter.CreateQrCode().AddBrandLogo()

何時團隊考慮從Aspose.BarCode轉向IronBarcode

幾個場景常常促使開發團隊將IronBarcode作為Aspose.BarCode的替代方案進行評估。

訂閱續約發生

年度訂閱續約是團隊最常重新考慮程式庫選擇的時機。 如果Aspose.BarCode是堆中的唯一Aspose產品,支付每年每個開發人員$999(或者站點級別$4,995/年)的條形碼功能促使了比較。 對話通常是這樣的:"這筆錢我們每年都在付。 IronBarcode的單次費用是多少?"在專業版級別(10個開發人員$2,999),與站點授權相比,IronBarcode在第一年內便能收回成本。

對於使用Aspose.Total的團隊——其中Aspose.BarCode與許多其他Aspose產品一起捆綁——數字有所不同。 Aspose.BarCode在該捆綁中的邊際成本接近於零。 這些團隊就更少理由去轉換。

PDF支持成為必須

許多專案開始時從影像中讀取條形碼,然後在利害關係人發現進件文件是PDF而非影像文件後增加了PDF支持。 這時,使用Aspose.BarCode的團隊面臨一個決定:加入Aspose.PDF(另一個訂閱),找到第三方PDF渲染器,或重新評估條形碼程式庫。

增加Aspose.PDF解決了當前需求但意味著第二個年度訂閱。 尋找第三方渲染器增加了依賴且需要進行整合努力。 重新評估條形碼程式庫——發現IronBarcode以一次性費用提供本地讀取PDF——通常是結果。

格式未知場景在生產中

面向客戶的應用接受文件上傳,無法控制一個上傳文件使用的是什麼條形碼格式。 如果應用建立在假設Code 128輸入的基礎上,而客戶上傳了一個DataMatrix標籤,一個硬編碼的DecodeType.Code128會默默地返回無結果。 更改為DecodeType.AllSupportedTypes修正了正確性但引入了一個性能成本。

已經遇到這個問題的團隊——隨著新的格式在生產中出現,將DecodeType值新增到其讀者配置中——經常最終需要維護一個列表,每次新增格式源後更新。 IronBarcode的自動檢測使該列表不再必要。

雲端和容器化部署

Aspose.BarCode的基於文件的授權新增了一個部署步驟:必須能在運行時從應用可讀取的路徑存取授權文件。 在GitOps工作流程中,授權文件最終要麼進入源程式碼控制(安全風險),要麼需要通過掛載的祕密卷進行注入。 IronBarcode的基於密鑰還不錯地適應了Kubernetes祕密和CI/CD祕密變數,無需在容器映像中管理文件。

常見的遷移考慮因素

過渡從Aspose.BarCode到IronBarcode的團隊遇到一小組可以預測的技術調整。

屬性名稱對應

更換包後最常見的編譯錯誤是result.Value的重命名。 整個程式碼庫的搜索很快就涵蓋了這一點:

grep -r "\.CodeText" --include="*.cs" .
grep -r "\.CodeTypeName" --include="*.cs" .
grep -r "\.CodeText" --include="*.cs" .
grep -r "\.CodeTypeName" --include="*.cs" .
SHELL

result.Valueresult.Format.ToString()BarcodeEncoding枚舉值,這也允許在需要時進行型別比對。

DecodeType刪除

程式碼庫中每個DecodeType.*引用都可以刪除:

grep -r "DecodeType\." --include="*.cs" .
grep -r "DecodeType\." --include="*.cs" .
SHELL

如果列出了特定BarcodeReaderOptions中提供了類似的好處,而不需要格式知識要求。

授權初始化更改

Aspose.BarCode使用一個license.SetLicense()載入。 IronBarcode使用一個字串密鑰:

IronBarCode.License.LicenseKey =
    Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE")
    ?? throw new InvalidOperationException("IronBarcode license key not configured");
IronBarCode.License.LicenseKey =
    Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE")
    ?? throw new InvalidOperationException("IronBarcode license key not configured");
Imports IronBarCode
Imports System

License.LicenseKey = If(Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE"), Throw New InvalidOperationException("IronBarcode license key not configured"))
$vbLabelText   $csharpLabel

從儲存庫和生成工件中刪除.lic文件。 在Docker中,刪除ENV IRONBARCODE_LICENSE條目。

EncodeTypes到BarcodeEncoding的映射

BarcodeEncoding.QRCode——命名差異是遷移生成程式碼後,團隊最常遭遇首次編譯錯誤的地方。 大多數其他映射是直接等效並具有一致的命名。

額外的IronBarcode能力

在核心比較點之外,IronBarcode提供根據應用上下文可能相關的功能:

.NET相容性和未來準備

IronBarcode支持.NET Framework 4.6.2+,.NET Core 3.1+和.NET 5、6、7、8。該程式庫定期更新,與Microsoft的.NET版本發佈節奏保持一致。 Aspose.BarCode支持一個相當的.NET版本範圍,因此沒有一個程式庫在當前版本中呈現出相容性優勢。 對未來準備的有意義的差異是授權:今天購買的永久IronBarcode授權涵蓋未來的.NET版本無需額外費用,而Aspose.BarCode訂閱需要持續續約以存取更新的構建版本。

結論

Aspose.BarCode和IronBarcode代表了兩種條形碼程式庫設計的不同理念。 Aspose.BarCode基於一個明確的、基於實例的API,調用者指定格式、管理物件的生命週期,並通過屬性層次結構配置每次操作。 IronBarcode則基於靜態、格式不可知的API,程式庫內部處理檢測、物件生命周期和PDF渲染。 兩種方法沒有哪個固有的正確——正確的選擇取決於應用的需要。

Aspose.BarCode對於已經在Aspose生態系統內運作的團隊來說是更強的選擇。 當Aspose.Total已經授權時,Aspose.BarCode增加不了邊際成本,而其80+的語法列表是任何商業.NET條形碼程式庫中最廣泛之一。 對於需要非標準格式的應用——MaxiCode、DotCode或IronBarcode 50+的列表中不存在的特定郵政語法——Aspose.BarCode可能是唯一可行選擇。 它的成熟度和格式廣度確實是其真實的優勢。

對於考慮將Aspose.BarCode作為單獨購買的團隊來說,其價值計算就更難做出。 格式規範要求為每次讀取操作增加了摩擦。 缺乏本地PDF支持使得在IronBarcode基礎包中包含的能力的訂閱成本翻番。 而且訂閱模型意味著每年成本累積——對於10個開發者的團隊,每年$4,995在五年內達到$24,975,相比之下IronBarcode業務版的一次性購買只需$2,999。 IronBarcode的自動檢測、本地PDF讀取和永久授權在一個包中解決了這三個問題。

最終的決定取決於生態系統的合適性和語法要求。 與Aspose產品深度整合的團隊,或需要IronBarcode支持列表外格式的團隊,屬於Aspose.BarCode。 希望單獨的永久授權、本地PDF讀取,以及一個不需要每次讀取都需格式知識的API的團隊會發現IronBarcode是更實際的選擇。

常見問題

什麼是 Aspose.BarCode for .NET?

Aspose.BarCode for .NET 是一個用於在 C#應用中生成和讀取條碼的 .NET 條碼程式庫。開發者在選擇 .NET 專案的條碼解決方案時會評估的多個替代方案之一。

Aspose.BarCode for .NET 和 IronBarcode 之間的主要區別是什麼?

IronBarcode 使用靜態、無狀態的 API,不需要實體管理,而 Aspose.BarCode for .NET 通常需要在使用前建立和配置實體。IronBarcode 還提供原生 PDF 支援、自動格式檢測和跨所有環境的單鍵授權。

IronBarcode 比 Aspose.BarCode for .NET 更容易授權嗎?

IronBarcode使用一個覆蓋開發和生產部署的單一授權金鑰。相比於將SDK金鑰與運行時金鑰分開的授權系統,這簡化了CI/CD管道和Docker配置。

IronBarcode 支援所有 Aspose.BarCode for .NET 支援的條碼格式嗎?

IronBarcode支持超過30種條碼符號,包括QR Code、Code 128、Code 39、DataMatrix、PDF417、Aztec、EAN-13、UPC-A、GS1等。格式自動檢測意味著不需要顯式的格式枚舉。

IronBarcode支持原生PDF條碼讀取嗎?

是的。IronBarcode可以直接從PDF文件中讀取條碼,使用BarcodeReader.Read("document.pdf"),無需單獨的PDF渲染程式庫。每頁結果包括頁碼、條碼格式、值和置信分數。

IronBarcode 如何處理批次處理相較於 Aspose.BarCode for .NET?

IronBarcode的靜態方法無狀態且天然執行緒安全,可以直接使用Parallel.ForEach而無需每個執行緒的實例管理。任何價格級別下都沒有吞吐量上限。

IronBarcode支持哪些.NET版本?

IronBarcode支持.NET Framework 4.6.2+、.NET Core 3.1,以及.NET 5、6、7、8和9,單一NuGet包。平台目標包括Windows x64/x86、Linux x64和macOS x64/ARM。

如何在.NET專案中安裝IronBarcode?

通過NuGet安裝IronBarcode:在Package Manager Console中運行 'Install-Package IronBarCode',或在CLI中運行 'dotnet add package IronBarCode'。不需要額外的SDK安裝程式或運行時文件。

我可以在購買之前評估 IronBarcode 嗎,不像 Aspose.BarCode?

可以。IronBarcode的試用模式返回完整解碼的條碼值——只有生成的輸出圖像上有水印。您可以在自己的文件上評估讀取準確性,然後再決定購買。

Aspose.BarCode for .NET 和 IronBarcode 之間的價格差異是什麼?

IronBarcode起價為$749,為單開發者所適用的永久授權,覆蓋開發和生產。價格詳情和批量選項可在IronBarcode授權頁面獲得。無需單獨的運行時授權。

從 Aspose.BarCode for .NET 遷移到 IronBarcode 是否簡單明瞭?

從 Aspose.BarCode for .NET 遷移到 IronBarcode 主要涉及將基於實例的 API 調用替換為 IronBarcode 的靜態方法,移除授權樣板,並更新結果屬性名稱。大多數遷移涉及減少程式碼而非增加程式碼。

IronBarcode可以生成帶有Logo的QR碼嗎?

可以。QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png") 可以原生嵌入品牌圖像進QR碼,並可配置錯誤更正。也支持通過ChangeBarCodeColor() 生成彩色QR碼。

Curtis Chau
技術作家

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

除了開發,Curtis對物聯網(IoT)有濃厚的興趣,探索創新的方法來整合硬體和軟體。在空閒時間,他喜歡玩遊戲和建立Discord機器人,結合他對技術的熱愛與創造力。

Iron 支援團隊

我們線上24小時,每週5天。
聊天
電子郵件
給我打電話