
如何使用IronBarcode讀取多個條碼:現場演示回顧
IronBarcode允許開發人員通過幾行C#程式碼建立和解釋各種條碼格式。 它支持從簡單的QR碼到複雜的多條碼文件處理,跨桌面、網路和移動平台的所有應用。
在最近的一次直播中,Iron Software團隊展示了如何使用IronBarcode生成和讀取多種條碼格式。 在由銷售工程師Shadman Majid和銷售主管Craig Beaumont主持的會議中,涵蓋了從簡單的條碼生成到高級讀取應用,展示了IronBarcode程式庫在現實應用中的快速和靈活。

網路研討會涵蓋了條碼生成的哪些內容?
Shadman首先解釋了如何使用IronBarcode只需少量C#程式碼即可輕鬆生成條碼。 該工具支持多種條碼格式,並使得將輸出自定義為PNG或PDF變得簡單。 這對於需要快速可靠的條碼生產的行業來說是理想的,從製造業到物流業。
IronBarcode程式庫提供了開發人員完整的API,來處理生成條碼所需的複雜數學和呈現。 不論您需要建立像Code 128和UPC-A這樣的簡單1D條碼,還是更複雜的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 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
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和掃描的文件中提取條碼資料。
-
物流與供應鏈 – 在整個運輸過程中實現實時跟踪。
-
醫療保健 – 通過準確的身份識別和用藥跟踪確保患者安全。
-
支付與售票 – 處理QR碼以進行進入驗證和數位交易。
-
製造業 – 監控生產線並維持質量控制標準。
-
銷售點(POS) – 使用即時的產品條碼掃描加快結帳速度。
-
安全和身份驗證 – 通過基於條碼的憑證驗證使用者。
IronBarcode如何處理單個和多個條碼讀取?
Shadman重新展示了IronBarcode如何在實時環境中處理單個和多個條碼讀取。

程式庫的智能檢測算法可以在單個圖像或文件頁面中識別和處理多個條碼,即使它們使用不同的編碼格式。 這種能力對於像運輸清單這樣的應用至關重要,可能包含跟踪條碼、產品程式碼和路由資訊。 多執行緒處理引擎確保即使是包含大量條碼的大型文件也能高效處理。
IronBarcode提取了哪些關鍵資訊?
- 單個條碼讀取 – 優化最快的讀取時間
- 條碼值 – 使用UTF-8支持的解碼資料
- 格式檢測 – 自動識別條碼型別
- 精確座標 – 像素級的x, y位置資料
- 完整的元資料 – 高度、寬度和編碼細節
超越基本提取,IronBarcode為每次讀取提供置信度分數,允許應用程式實施適合其使用案例的質量門檻。 對於像藥品標籤或金融文件處理這樣的關鍵應用,這確保了只有高置信度的讀取被接受,而不太重要的應用可以配置為最大吞吐量。
為什麼要在您的專案中使用IronBarcode?
使用IronBarcode,開發者可以輕鬆生成和讀取各種格式和平台的條碼,包括桌面、網頁,現在甚至通過.NET MAUI支持移動裝置。 無論您是在構建倉庫跟踪系統還是零售結賬應用,IronBarcode提供了必要的靈活性和性能,以快速完成工作。
程式庫的跨平台支持意味著您可以在Windows、Linux、macOS、iOS和Android上部署相同的條碼邏輯而無需修改。 這種一次書寫,隨處運行的方式大大減少了開發時間和維護成本。 結合完整的文件和快速響應的支持,IronBarcode幫助團隊更快地交付條碼功能,無需從頭建立或整合多個專業程式庫。
對於 評估條碼解決方案的企業,IronBarcode提供了幾個關鍵優勢:部署無運行時費用,執行緒安全操作支持網路應用程式,並能與現有.NET程式碼庫相容。 程式庫能處理常常困擾簡單解決方案的邊緣情況,比如從傳真文件中讀取條碼,處理具有混合方向的批次掃描,或生成具有自定義樣式以符合品牌準則的條碼。
準備好試試看? 立即獲取30天免費試用。

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


