如何使用IronBarcode讀取多個條碼:現場演示回顧
IronBarcode 允許開發人員僅使用幾行 C# 程式碼即可建立和解釋各種條碼格式。 它支援從簡單的二維碼到複雜的多條碼文件處理,並可在桌面、網路和行動平台上運行。
在最近的一次直播中,Iron Software 團隊示範如何使用 IronBarcode 來產生和讀取多種條碼格式。 本次會議由銷售工程師 Shadman Majid 和銷售主管 Craig Beaumont 主持,內容涵蓋從簡單的條碼生成到高級讀取用例的所有內容,展示了 IronBarcode 庫在實際應用中的速度和靈活性。
本次網路研討會涵蓋了條碼生成的哪些內容?
Shadman 首先解釋了使用 IronBarcode 只需幾行 C# 程式碼即可輕鬆產生條碼。 該工具支援多種條碼格式,並可輕鬆自訂輸出格式,例如 PNG 或 PDF。 從製造業到物流業,這對於需要快速可靠產生條碼的行業來說非常理想。
IronBarcode 庫為開發者提供了一個完整的 API,可以處理條碼產生所需的複雜數學運算和渲染。 無論您需要建立簡單的 1D 條碼(如 Code 128 和 UPC-A),還是更複雜的 2D 格式(如 QR 碼和 Data Matrix),該程式庫都會抽象化技術細節,同時讓您完全控制外觀和編碼選項。
// Example C# code to generate various barcode formats using IronBarcode
using IronBarCode;
// Generate a QR code with custom text
BarcodeWriter.CreateBarcode("Hello World!", BarcodeEncoding.QRCode)
.SaveAsPng("HelloWorldQRCode.png");
// Generate a Code 128 barcode with product information
BarcodeWriter.CreateBarcode("PROD-12345-2024", BarcodeEncoding.Code128)
.ResizeTo(400, 100) // Custom dimensions in pixels
.AddBarcodeValueTextBelowBarcode() // Add human-readable text
.SaveAsPng("ProductBarcode.png");
// Generate a Data Matrix barcode for compact data storage
BarcodeWriter.CreateBarcode("Compact data for small labels", BarcodeEncoding.DataMatrix)
.SaveAsPdf("DataMatrixLabel.pdf");
// Example C# code to generate various barcode formats using IronBarcode
using IronBarCode;
// Generate a QR code with custom text
BarcodeWriter.CreateBarcode("Hello World!", BarcodeEncoding.QRCode)
.SaveAsPng("HelloWorldQRCode.png");
// Generate a Code 128 barcode with product information
BarcodeWriter.CreateBarcode("PROD-12345-2024", BarcodeEncoding.Code128)
.ResizeTo(400, 100) // Custom dimensions in pixels
.AddBarcodeValueTextBelowBarcode() // Add human-readable text
.SaveAsPng("ProductBarcode.png");
// Generate a Data Matrix barcode for compact data storage
BarcodeWriter.CreateBarcode("Compact data for small labels", BarcodeEncoding.DataMatrix)
.SaveAsPdf("DataMatrixLabel.pdf");
' Example VB.NET code to generate various barcode formats using IronBarcode
Imports IronBarCode
' Generate a QR code with custom text
BarcodeWriter.CreateBarcode("Hello World!", BarcodeEncoding.QRCode) _
.SaveAsPng("HelloWorldQRCode.png")
' Generate a Code 128 barcode with product information
BarcodeWriter.CreateBarcode("PROD-12345-2024", BarcodeEncoding.Code128) _
.ResizeTo(400, 100) ' Custom dimensions in pixels
.AddBarcodeValueTextBelowBarcode() ' Add human-readable text
.SaveAsPng("ProductBarcode.png")
' Generate a Data Matrix barcode for compact data storage
BarcodeWriter.CreateBarcode("Compact data for small labels", BarcodeEncoding.DataMatrix) _
.SaveAsPdf("DataMatrixLabel.pdf")
以上程式碼片段示範如何產生具有自訂選項的不同條碼格式。 該函式庫會自動處理每種格式的編碼規則、錯誤修正和渲染最佳化。 對於實施基於條碼的庫存系統的企業而言,這種靈活性意味著您可以適應任何標籤要求而無需更換工具。
如何使用 IronBarcode 讀取多種條碼格式?
在生成演示之後,Craig 接手演示了 IronBarcode 的條碼讀取功能。
這些特性使得 IronBarcode 非常適合複雜的自動化工作流程,尤其是當文件可能包含多種條碼類型或處理大量資料時。 該圖書館先進的圖像處理能力可以檢測和解碼條碼,即使來自不完美的來源——包括傾斜的掃描、低解析度的照片或部分損壞的標籤。 這種可靠性對於無法保證完美條件的實際應用至關重要。
// Complete example of reading barcodes with advanced options
using IronBarCode;
using System;
using System.Linq;
// Read all barcodes in a given image file
var results = BarcodeReader.Read(@"exampleImageWithBarcodes.png");
// Process each barcode read with detailed information
foreach (var result in results)
{
Console.WriteLine($"Value: {result.Value}");
Console.WriteLine($"Format: {result.BarcodeType}");
Console.WriteLine($"Position: X={result.X}, Y={result.Y}");
Console.WriteLine($"Dimensions: {result.Width}x{result.Height}");
Console.WriteLine("---");
}
// Read with specific options for challenging scenarios
var advancedResults = BarcodeReader.ReadAsync(
@"lowQualityDocument.pdf",
new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced, // Balance between speed and accuracy
ExpectMultipleBarcodes = true, // Improve for multiple barcode detection
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128, // Filter specific types
CropArea = new System.Drawing.Rectangle(100, 100, 500, 500) // Focus on specific region
}
).Result;
// Handle results with error checking
if (advancedResults.Any())
{
Console.WriteLine($"Found {advancedResults.Count()} barcodes in the document");
}
// Complete example of reading barcodes with advanced options
using IronBarCode;
using System;
using System.Linq;
// Read all barcodes in a given image file
var results = BarcodeReader.Read(@"exampleImageWithBarcodes.png");
// Process each barcode read with detailed information
foreach (var result in results)
{
Console.WriteLine($"Value: {result.Value}");
Console.WriteLine($"Format: {result.BarcodeType}");
Console.WriteLine($"Position: X={result.X}, Y={result.Y}");
Console.WriteLine($"Dimensions: {result.Width}x{result.Height}");
Console.WriteLine("---");
}
// Read with specific options for challenging scenarios
var advancedResults = BarcodeReader.ReadAsync(
@"lowQualityDocument.pdf",
new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced, // Balance between speed and accuracy
ExpectMultipleBarcodes = true, // Improve for multiple barcode detection
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128, // Filter specific types
CropArea = new System.Drawing.Rectangle(100, 100, 500, 500) // Focus on specific region
}
).Result;
// Handle results with error checking
if (advancedResults.Any())
{
Console.WriteLine($"Found {advancedResults.Count()} barcodes in the document");
}
' Complete example of reading barcodes with advanced options
Imports IronBarCode
Imports System
Imports System.Linq
' Read all barcodes in a given image file
Dim results = BarcodeReader.Read("exampleImageWithBarcodes.png")
' Process each barcode read with detailed information
For Each result In results
Console.WriteLine($"Value: {result.Value}")
Console.WriteLine($"Format: {result.BarcodeType}")
Console.WriteLine($"Position: X={result.X}, Y={result.Y}")
Console.WriteLine($"Dimensions: {result.Width}x{result.Height}")
Console.WriteLine("---")
Next
' Read with specific options for challenging scenarios
Dim advancedResults = BarcodeReader.ReadAsync(
"lowQualityDocument.pdf",
New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced, ' Balance between speed and accuracy
.ExpectMultipleBarcodes = True, ' Improve for multiple barcode detection
.ExpectBarcodeTypes = BarcodeEncoding.QRCode Or BarcodeEncoding.Code128, ' Filter specific types
.CropArea = New System.Drawing.Rectangle(100, 100, 500, 500) ' Focus on specific region
}
).Result
' Handle results with error checking
If advancedResults.Any() Then
Console.WriteLine($"Found {advancedResults.Count()} barcodes in the document")
End If
此程式碼範例展示如何使用基本配置和進階配置讀取條碼。 BarcodeReaderOptions 類別提供了對讀取過程的精細控制,讓開發人員可以針對速度、準確性或特定用例進行改進。 在批量處理數千份文件或處理具有挑戰性的原始材料時,這種控制水平尤其有價值。
各行業常見的應用場景有哪些?
Craig 也分享了一些 IronBarcode 已經產生影響力的實際應用案例:
*庫存與資產管理– 追蹤庫存水準並實現倉庫作業自動化。
*文件處理– 自動從 PDF 和掃描文件中提取條碼資料。
*物流與供應鏈– 實現整個運輸過程的即時追蹤。
*醫療保健– 透過準確的識別和用藥追蹤來確保病人安全。
-
付款和票務 – 處理用於入場驗證和數位交易的二維碼。
-
生產製造 – 監控生產線並維持品質控制標準。
-
銷售點 (POS) – 透過即時掃描產品條碼加快結帳速度。
- 安全性與驗證 – 透過基於條碼的憑證驗證使用者身分。
IronBarcode 如何處理單次和多次條碼讀取?
Shadman 再次示範了 IronBarcode 如何即時處理單一和多個條碼讀取。
該庫的智慧型偵測演算法可以識別和處理單一影像或文件頁面中的多個條碼,即使它們使用不同的編碼格式。 對於諸如貨運清單之類的應用來說,這項功能至關重要,因為貨運清單可能在同一標籤上包含追蹤條碼、產品代碼和路線資訊。 多執行緒處理引擎確保即使是包含大量條碼的大型文件也能高效處理。
IronBarcode會擷取哪些關鍵資訊?
- 單條碼讀取 – 針對最快讀取速度進行了最佳化
- 條碼值 – 支援 UTF-8 的解碼數據
- 格式偵測 – 自動辨識條碼類型
- 精確座標 – 像素級 x、y 位置數據
- 完整的元資料-高度、寬度和編碼詳情
除了基本的提取功能外,IronBarcode 還提供每次讀取的置信度評分,使應用程式能夠根據其用例實施適當的品質閾值。 對於像藥品標籤或財務文件處理這樣的關鍵任務應用,這確保只接受高置信度的讀取,而不太重要的應用可以配置為最大吞吐量。
為什麼您的專案應該使用 IronBarcode?
借助 IronBarcode,開發人員可以輕鬆地在各種格式和平台上產生和讀取條碼,包括桌面、Web,現在甚至可以透過 .NET MAUI 在行動裝置上讀取。 無論您是建立倉庫追蹤系統還是零售結帳應用程式,IronBarcode 都能提供完成工作所需的靈活性和效能。
該程式庫的跨平台支援意味著您可以將相同的條碼邏輯部署到 Windows、Linux、macOS、iOS 和 Android 上,而無需進行任何修改。 這種一次編寫、到處運作的方法可以顯著降低開發時間和維護成本。 IronBarcode 結合了完整的文件和快速回應的支持,可以幫助團隊更快地交付條碼功能,比從頭開始建立或整合多個專用庫快得多。
對於正在評估條碼解決方案的企業而言,IronBarcode 提供了幾個關鍵優勢:部署無需執行時間費用、Web 應用程式執行緒安全操作以及與現有 .NET 程式碼庫的兼容性。 該庫可以處理一些簡單的解決方案經常遇到的極端情況,例如從傳真文件中讀取條碼、處理混合方向的批量掃描,或產生具有自訂樣式以符合品牌指南的條碼。
準備好嘗試了嗎? 立即取得30天免費試用。
常見問題解答
如何在 C# 中生成條碼?
您可以使用 IronBarcode 在 C# 中生成條碼。通過使用 BarcodeWriter.CreateBarcode 方法,您可以創建各種條碼格式,並將其保存為像 PNG 或 PDF 的圖像。
如何在 C# 中從圖像讀取多個條碼的步驟是什麼?
要從圖像中讀取多個條碼,請使用 IronBarcode 的 BarcodeReader.Read 方法。這允許您高效處理包含多種條碼格式的圖像並提取其值和類型。
哪些行業受益於使用條碼庫?
製造、物流、醫療保健和零售等行業受益於使用 IronBarcode 這樣的條碼庫。它們支持條碼生成和讀取,用於庫存管理、文件處理和 POS 系統的高效任務。
IronBarcode 能處理即時條碼掃描嗎?
是的,IronBarcode 能夠處理即時條碼掃描。它支持在即時場景中讀取單個及多個條碼,適合需要即時條碼處理的應用。
IronBarcode 可以在哪些平台上使用?
IronBarcode 可以在桌面、Web 和移動平台上使用。它支持使用像 .NET MAUI 這樣的框架進行跨平台開發,使開發人員能夠將條碼功能整合到多樣化的應用中。
是否有免費試用可以評估 IronBarcode?
是的,IronBarcode 提供 30 天的免費試用。這讓開發者能在購買決定之前探索其功能並評估其性能。
IronBarcode 如何支持自動化工作流程?
IronBarcode 支持自動化工作流程,通過使能從文件和圖像中讀取多種條碼格式。這種功能對於自動化物流和文件管理等行業的流程至關重要。
IronBarcode 在現場會議中展示的主要功能是什麼?
在現場會議中,展示的主要功能包括簡化代碼的條碼生成、閱讀多種條碼格式,以及自定義條碼輸出以滿足各種行業應用的能力。

