如何在C#中使用IronBarcode讀取.NET 5中的條碼
從Google ML Kit條碼掃描遷移到IronBarcode
本指南適用於兩種情況的團隊:您正在將Android應用程式移植到.NET MAUI或.NET 9,並需要替換ML Kit的條碼掃描器,或者在跨平台條碼討論中被推薦使用Google ML Kit,並且在嘗試加入NuGet套件時發現它不存在。
Google ML Kit條碼掃描是一個原生的Android和iOS程式庫。 它作為一個Maven依賴項(GoogleMLKit/BarcodeScanning)提供給Swift。 ML Kit自2020年6月以來成為一個獨立產品,不再需要Firebase,但並沒有官方的.NET SDK,沒有dotnet add package google-mlkit-barcode,也沒有來自Google的第一方C# API。 社群維護的Xamarin/MAUI綁定這些年來已經出現,但當ML Kit更新其底層SDK時,它們會失效。
IronBarcode是一個原生的.NET程式庫,可以從NuGet安裝,整合到標準的.NET模式中,並在Windows、Linux、macOS、Docker、Azure和AWS上運行。 本指南展示如何將您在Kotlin或Java中寫的模式轉換成等效的C#程式碼。
移植背景
從ML Kit移植到IronBarcode時,結構上有幾個變化——不僅僅是語法上的:
回呼變成返回值。 ML Kit使用Android的Task API,使用addOnFailureListener。 IronBarcode的BarcodeReader.Read()同步返回一個集合。 您可以直接迭代它。 無需回呼註冊,無需執行緒協調。
無掃描器物件。 ML Kit要求您構建一個scanner.process(inputImage)。 IronBarcode使用靜態方法——BarcodeReader.Read()是進入點。 無需管理或處置實例。
無InputImage構造。 ML Kit的InputImage.fromMediaImage(image, rotation)。 IronBarcode接受檔案路徑字串、System.Drawing.Bitmap。 無需Android上下文,無需URI,無需旋轉元資料。
無Google Play Services。 未打包的ML Kit模型通過Google Play Services運行。 打包變體將模型引入APK內部(約增加2.4 MB),避免了Play Services檢查,但這兩個變體都無法在.NET目標上使用。 IronBarcode無此類依賴——它以.NET支援的任何平台上相同運行。
.NET中的快速設置
如果您的專案中存在任何Xamarin/MAUI ML Kit綁定套件,請將其移除,然後安裝IronBarcode:
dotnet add package BarCode
在應用程式啟動時新增授權密鑰——基於應用程式型別,這可以在Startup.cs中完成:
// NuGet: dotnet add package BarCode
using IronBarCode;
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
// NuGet: dotnet add package BarCode
using IronBarCode;
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
Imports IronBarCode
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"
可以在第一次BarcodeWriter.CreateBarcode()調用之前的任何點設置授權。 免費試用可用; 試用模式會水印生成的條碼,但不會限制讀取。
閱讀條碼:從Kotlin到C
基本單一條碼讀取
這是Kotlin中典型的ML Kit讀取,一個檔案URI中的單一QR碼掃描:
// Android Kotlin — ML Kit
val options = BarcodeScannerOptions.Builder()
.setBarcodeFormats(Barcode.FORMAT_QR_CODE)
.build()
val scanner = BarcodeScanning.getClient(options)
val inputImage = InputImage.fromFilePath(context, imageUri)
scanner.process(inputImage)
.addOnSuccessListener { barcodes ->
val barcode = barcodes.firstOrNull()
if (barcode != null) {
Log.d("MLKit", "Value: ${barcode.rawValue}")
Log.d("MLKit", "Format: ${barcode.format}")
}
}
.addOnFailureListener { e ->
Log.e("MLKit", "Scan failed: ${e.message}")
}
在C#中使用IronBarcode的等效程式碼:
using IronBarCode;
try
{
var results = BarcodeReader.Read("captured-image.jpg");
var barcode = results.FirstOrDefault();
if (barcode != null)
{
Console.WriteLine($"Value: {barcode.Value}");
Console.WriteLine($"Format: {barcode.Format}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Scan failed: {ex.Message}");
}
using IronBarCode;
try
{
var results = BarcodeReader.Read("captured-image.jpg");
var barcode = results.FirstOrDefault();
if (barcode != null)
{
Console.WriteLine($"Value: {barcode.Value}");
Console.WriteLine($"Format: {barcode.Format}");
}
}
catch (Exception ex)
{
Console.WriteLine($"Scan failed: {ex.Message}");
}
Imports IronBarCode
Try
Dim results = BarcodeReader.Read("captured-image.jpg")
Dim barcode = results.FirstOrDefault()
If barcode IsNot Nothing Then
Console.WriteLine($"Value: {barcode.Value}")
Console.WriteLine($"Format: {barcode.Format}")
End If
Catch ex As Exception
Console.WriteLine($"Scan failed: {ex.Message}")
End Try
結果立即作為返回值可用。 barcode.rawValue。 barcode.format。 錯誤處理使用標準的try/catch,而非單獨的故障監聽器。
多條碼讀取
ML Kit掃描單個InputImage並返回列表。對於一幅圖像中的多個條碼,您迭代成功監聽器的列表:
// Android Kotlin — ML Kit, multiple barcodes
val options = BarcodeScannerOptions.Builder()
.setBarcodeFormats(Barcode.FORMAT_ALL_FORMATS)
.build()
val scanner = BarcodeScanning.getClient(options)
val inputImage = InputImage.fromFilePath(context, imageUri)
scanner.process(inputImage)
.addOnSuccessListener { barcodes ->
for (barcode in barcodes) {
val rawValue = barcode.rawValue
val format = barcode.format
processBarcode(rawValue, format)
}
}
.addOnFailureListener { e -> Log.e("MLKit", e.message ?: "Unknown error") }
使用IronBarcode,設置BarcodeReaderOptions中,並迭代結果集合:
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true
};
var results = BarcodeReader.Read("warehouse-shelf.jpg", options);
foreach (var barcode in results)
{
Console.WriteLine($"Format: {barcode.Format}, Value: {barcode.Value}");
ProcessBarcode(barcode.Value, barcode.Format);
}
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true
};
var results = BarcodeReader.Read("warehouse-shelf.jpg", options);
foreach (var barcode in results)
{
Console.WriteLine($"Format: {barcode.Format}, Value: {barcode.Value}");
ProcessBarcode(barcode.Value, barcode.Format);
}
Imports IronBarCode
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True
}
Dim results = BarcodeReader.Read("warehouse-shelf.jpg", options)
For Each barcode In results
Console.WriteLine($"Format: {barcode.Format}, Value: {barcode.Value}")
ProcessBarcode(barcode.Value, barcode.Format)
Next
格式規範:從setBarcodeFormats到BarcodeReaderOptions
ML Kit要求您通過setBarcodeFormats()指定要查找的格式。 如果您省略它,ML Kit會搜索所有格式。 IronBarcode的工作方式相同——省略格式限制會搜索所有格式,但指定預期型別可以提高性能。
| ML Kit Kotlin | IronBarcodeC# |
|---|---|
Barcode.FORMAT_QR_CODE |
BarcodeEncoding.QRCode |
Barcode.FORMAT_CODE_128 |
BarcodeEncoding.Code128 |
Barcode.FORMAT_CODE_39 |
BarcodeEncoding.Code39 |
Barcode.FORMAT_CODE_93 |
BarcodeEncoding.Code93 |
Barcode.FORMAT_EAN_13 |
BarcodeEncoding.EAN13 |
Barcode.FORMAT_EAN_8 |
BarcodeEncoding.EAN8 |
Barcode.FORMAT_UPC_A |
BarcodeEncoding.UPCA |
Barcode.FORMAT_UPC_E |
BarcodeEncoding.UPCE |
Barcode.FORMAT_PDF417 |
BarcodeEncoding.PDF417 |
Barcode.FORMAT_DATA_MATRIX |
BarcodeEncoding.DataMatrix |
Barcode.FORMAT_AZTEC |
BarcodeEncoding.Aztec |
Barcode.FORMAT_ITF |
BarcodeEncoding.ITF |
Barcode.FORMAT_CODABAR |
BarcodeEncoding.Codabar |
Barcode.FORMAT_ALL_FORMATS |
省略ExpectBarcodeTypes |
在IronBarcode中使用格式標誌:
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128 | BarcodeEncoding.EAN13
};
var results = BarcodeReader.Read("product-image.jpg", options);
using IronBarCode;
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true,
ExpectBarcodeTypes = BarcodeEncoding.QRCode | BarcodeEncoding.Code128 | BarcodeEncoding.EAN13
};
var results = BarcodeReader.Read("product-image.jpg", options);
Imports IronBarCode
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True,
.ExpectBarcodeTypes = BarcodeEncoding.QRCode Or BarcodeEncoding.Code128 Or BarcodeEncoding.EAN13
}
Dim results = BarcodeReader.Read("product-image.jpg", options)
按位或組合與ML Kit的可變參數格式列表的工作方式相同。
結果存取:rawValue和format
ML Kit的結果物件公開Int常數)。 IronBarcode的結果公開BarcodeEncoding列舉值)。
// ML Kit Kotlin — result fields
val rawValue: String? = barcode.rawValue
val format: Int = barcode.format
val boundingBox: Rect? = barcode.boundingBox
val displayValue: String? = barcode.displayValue
//IronBarcodeC# — result fields
string value = barcode.Value;
BarcodeEncoding format = barcode.Format;
int page = barcode.PageNumber; // populated for PDF / multi-page input
//IronBarcodeC# — result fields
string value = barcode.Value;
BarcodeEncoding format = barcode.Format;
int page = barcode.PageNumber; // populated for PDF / multi-page input
'IronBarcodeVB.NET — result fields
Dim value As String = barcode.Value
Dim format As BarcodeEncoding = barcode.Format
Dim page As Integer = barcode.PageNumber ' populated for PDF / multi-page input
barcode.Value在IronBarcode中始終是一個非空字串——如果讀取成功,值存在。 if (barcode.Format == BarcodeEncoding.QRCode)。
.NET中有什麼不同
同步API而非回呼。這是最重要的結構變化。 ML Kit的Task<List<Barcode>>——您可以串接監聽器。 IronBarcode的Task.Run()中:
using IronBarCode;
// In a MAUI ViewModel or page code-behind
var results = await Task.Run(() => BarcodeReader.Read(imagePath));
foreach (var barcode in results)
{
// update UI on main thread
MainThread.BeginInvokeOnMainThread(() =>
{
ResultLabel.Text = barcode.Value;
});
}
using IronBarCode;
// In a MAUI ViewModel or page code-behind
var results = await Task.Run(() => BarcodeReader.Read(imagePath));
foreach (var barcode in results)
{
// update UI on main thread
MainThread.BeginInvokeOnMainThread(() =>
{
ResultLabel.Text = barcode.Value;
});
}
Imports IronBarCode
Imports System.Threading.Tasks
Imports Microsoft.Maui.Dispatching
' In a MAUI ViewModel or page code-behind
Dim results = Await Task.Run(Function() BarcodeReader.Read(imagePath))
For Each barcode In results
' update UI on main thread
MainThread.BeginInvokeOnMainThread(Sub()
ResultLabel.Text = barcode.Value
End Sub)
Next
無上下文參數。 每個構造InputImage的ML Kit調用需要Android Context。 IronBarcode僅需要一個檔案路徑或流。 從條碼邏輯中移除上下文執行緒大大簡化了程式碼。
無Google Play Services。 標準的ML Kit模型通過Play Services運行——BarcodeScanning.getClient()在運行時檢查Play Services的可用性,並在不可用時引發異常。 IronBarcode沒有運行時服務檢查。 它要麼讀取圖像,要麼拋出標準異常。
標準異常處理。 ML Kit的addOnFailureListener接收Java Exception子類。 在.NET中,故障以標準System.Exception拋出,在正常情況下可通過try/catch捕獲。
從PDF文件中讀取
ML Kit不支援PDF。 .pdf URI要麼失敗,要麼視Android版本而定僅讀取第一頁為光柵圖像。 如果您的移植場景涉及文件——例如發票處理、物流清單、表格掃描——IronBarcode可以原生處理PDF:
using IronBarCode;
// Read all barcodes from all pages of a PDF
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true
};
var results = BarcodeReader.Read("invoice-batch.pdf", options);
foreach (var barcode in results)
{
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}");
}
using IronBarCode;
// Read all barcodes from all pages of a PDF
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Balanced,
ExpectMultipleBarcodes = true
};
var results = BarcodeReader.Read("invoice-batch.pdf", options);
foreach (var barcode in results)
{
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}");
}
Imports IronBarCode
' Read all barcodes from all pages of a PDF
Dim options As New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Balanced,
.ExpectMultipleBarcodes = True
}
Dim results = BarcodeReader.Read("invoice-batch.pdf", options)
For Each barcode In results
Console.WriteLine($"Page {barcode.PageNumber}: {barcode.Format} — {barcode.Value}")
Next
無需圖像提取步驟,無需第三方PDF程式庫,無需單獨的渲染的頁面迭代迴圈。 傳遞PDF路徑,返回所有條碼值及其頁碼。
新功能:生成
ML Kit不生成條碼——它只讀取它們。 如果您的移植應用程式需要生成標籤、票證或QR碼,IronBarcode可以使用相同套件解決。
碼128,用於運輸標籤:
using IronBarCode;
BarcodeWriter.CreateBarcode("SHIP-2024-98341", BarcodeEncoding.Code128)
.ResizeTo(400, 120)
.SaveAsPng("shipping-label.png");
using IronBarCode;
BarcodeWriter.CreateBarcode("SHIP-2024-98341", BarcodeEncoding.Code128)
.ResizeTo(400, 120)
.SaveAsPng("shipping-label.png");
Imports IronBarCode
BarcodeWriter.CreateBarcode("SHIP-2024-98341", BarcodeEncoding.Code128) _
.ResizeTo(400, 120) _
.SaveAsPng("shipping-label.png")
QR碼生成:
using IronBarCode;
QRCodeWriter.CreateQrCode("https://example.com/track/98341", 500)
.SaveAsPng("tracking-qr.png");
using IronBarCode;
QRCodeWriter.CreateQrCode("https://example.com/track/98341", 500)
.SaveAsPng("tracking-qr.png");
Imports IronBarCode
QRCodeWriter.CreateQrCode("https://example.com/track/98341", 500) _
.SaveAsPng("tracking-qr.png")
帶有標誌和顏色的QR碼:
using IronBarCode;
QRCodeWriter.CreateQrCode("https://example.com/product/4821", 500)
.AddBrandLogo("company-logo.png")
.ChangeBarCodeColor(System.Drawing.Color.DarkBlue)
.SaveAsPng("product-qr.png");
using IronBarCode;
QRCodeWriter.CreateQrCode("https://example.com/product/4821", 500)
.AddBrandLogo("company-logo.png")
.ChangeBarCodeColor(System.Drawing.Color.DarkBlue)
.SaveAsPng("product-qr.png");
Imports IronBarCode
QRCodeWriter.CreateQrCode("https://example.com/product/4821", 500) _
.AddBrandLogo("company-logo.png") _
.ChangeBarCodeColor(System.Drawing.Color.DarkBlue) _
.SaveAsPng("product-qr.png")
將條碼以字節陣列形式返回,以便HTTP回應:
using IronBarCode;
// In an ASP.NET Core controller action
byte[] barcodeBytes = BarcodeWriter.CreateBarcode("ORDER-7734", BarcodeEncoding.QRCode)
.ToPngBinaryData();
return File(barcodeBytes, "image/png");
using IronBarCode;
// In an ASP.NET Core controller action
byte[] barcodeBytes = BarcodeWriter.CreateBarcode("ORDER-7734", BarcodeEncoding.QRCode)
.ToPngBinaryData();
return File(barcodeBytes, "image/png");
Imports IronBarCode
' In an ASP.NET Core controller action
Dim barcodeBytes As Byte() = BarcodeWriter.CreateBarcode("ORDER-7734", BarcodeEncoding.QRCode).ToPngBinaryData()
Return File(barcodeBytes, "image/png")
這些模式在ML Kit中無等效。 它們是因為您正在使用完整.NET條碼程式庫而非僅限移動的掃描器而提供的新功能。
伺服器端批次處理
ML Kit每呼叫處理一個圖像,需要Android/iOS運行時,並且不具有伺服器端執行的概念。 IronBarcode在迴圈中處理檔案,運行在ASP.NET Core,並正常擴展:
using IronBarCode;
// Process a folder of scanned document images
var imageFiles = Directory.GetFiles("/data/scans", "*.jpg");
var allResults = new List<(string File, string Value, BarcodeEncoding Format)>();
foreach (var file in imageFiles)
{
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Faster,
ExpectMultipleBarcodes = false
};
var results = BarcodeReader.Read(file, options);
foreach (var barcode in results)
{
allResults.Add((file, barcode.Value, barcode.Format));
}
}
// Write results to CSV, database, etc.
foreach (var (file, value, format) in allResults)
{
Console.WriteLine($"{file}: [{format}] {value}");
}
using IronBarCode;
// Process a folder of scanned document images
var imageFiles = Directory.GetFiles("/data/scans", "*.jpg");
var allResults = new List<(string File, string Value, BarcodeEncoding Format)>();
foreach (var file in imageFiles)
{
var options = new BarcodeReaderOptions
{
Speed = ReadingSpeed.Faster,
ExpectMultipleBarcodes = false
};
var results = BarcodeReader.Read(file, options);
foreach (var barcode in results)
{
allResults.Add((file, barcode.Value, barcode.Format));
}
}
// Write results to CSV, database, etc.
foreach (var (file, value, format) in allResults)
{
Console.WriteLine($"{file}: [{format}] {value}");
}
Imports IronBarCode
Imports System.IO
' Process a folder of scanned document images
Dim imageFiles = Directory.GetFiles("/data/scans", "*.jpg")
Dim allResults = New List(Of (File As String, Value As String, Format As BarcodeEncoding))()
For Each file In imageFiles
Dim options = New BarcodeReaderOptions With {
.Speed = ReadingSpeed.Faster,
.ExpectMultipleBarcodes = False
}
Dim results = BarcodeReader.Read(file, options)
For Each barcode In results
allResults.Add((file, barcode.Value, barcode.Format))
Next
Next
' Write results to CSV, database, etc.
For Each result In allResults
Console.WriteLine($"{result.File}: [{result.Format}] {result.Value}")
Next
此模式——讀取圖像文件夾,提取條碼,聚合結果——在ML Kit中不可能。 這是標準的IronBarcode工作流。
功能比較
| 功能 | Google ML Kit | IronBarcode |
|---|---|---|
| .NET NuGet套件 | None | BarCode |
| C# / .NET API | None | 是 |
| 條碼讀取 | 是(Android/iOS) | 是(所有平台) |
| 條碼生成 | 否 | 是 |
| QR 碼生成 | 否 | 是 |
| QR標誌嵌入 | 否 | 是 |
| PDF輸入 | 否 | 是 |
| 多頁文件支援 | 否 | 是 |
| 相機/框架輸入 | 是 | 通過圖片檔 |
| 伺服器端部署 | 否 | 是 |
| ASP.NET Core | 否 | 是 |
| Azure 功能 | 否 | 是 |
| Docker / Linux | 否 | 是 |
| 需要Google Play Services | 僅未打包變體 | 否 |
| 需要Firebase依賴 | 不(自2020年6月起獨立) | 否 |
| 同步的.NET API | 否 | 是 |
| 相容依賴注入 | 否 | 是(靜態API) |
ExpectMultipleBarcodes選項 |
通過結果列表 | BarcodeReaderOptions |
| 格式規範 | setBarcodeFormats() |
ExpectBarcodeTypes |
| 速度/準確性權衡 | 固定(基於模型) | ReadingSpeed枚舉 |
| 價格 | 免費(僅離線,僅移動) | 從$749(Lite)永久 |
| 平台 | Android, iOS | Windows, Linux, macOS, Docker, Azure, AWS |
遷移檢查清單
如果您正在移植Android程式碼庫或替換非官方的Xamarin ML Kit綁定,請在專案中搜尋這些模式並應用上面的翻譯:
- Gradle檔中的
com.google.mlkit:barcode-scanning→ 删除,新增BarCodeNuGet BarcodeScannerOptions.Builder()→new BarcodeReaderOptions { }BarcodeScanning.getClient(options)→ 删除(在IronBarcode中無掃描器實例)InputImage.fromFilePath(context, uri)→ 檔案路徑字串參數InputImage.fromBitmap(bitmap, rotation)→BarcodeReader.Read(stream)或字節陣列重載scanner.process(inputImage)→BarcodeReader.Read(path, options).addOnSuccessListener { barcodes -> }→ 遍歷Read()的返回值.addOnFailureListener { e -> }→ 在Read()周圍嘗試/捕獲barcode.rawValue→barcode.Valuebarcode.format→barcode.FormatBarcode.FORMAT_QR_CODE→BarcodeEncoding.QRCodeBarcode.FORMAT_CODE_128→BarcodeEncoding.Code128Barcode.FORMAT_ALL_FORMATS→ 省略ExpectBarcodeTypesusing Google.MLKit.BarcodeScanning;(Xamarin綁定) →using IronBarCode;IronBarCode.License.LicenseKey應該在Startup.cs中設定
從基於回呼的結構更改為同步程式碼是主要工作。 格式常數和結果字段名稱是直接映射。 PDF和生成支援是純粹的附加功能——它們不需要遷移,僅需新程式碼。
常見問題
為什麼我應該從Google ML Kit條碼掃描遷移到IronBarcode?
常見的理由包括簡化授權(去除SDK +運行時鑰匙的複雜性)、消除吞吐量限制、獲得原生PDF支持、改善Docker/CI/CD部署,並減少生產程式碼中的API樣板。
如何將Google ML Kit API調用替換為IronBarcode?
用IronBarCode.License.LicenseKey = "key"替換實例建立和授權樣板。用BarcodeReader.Read(path)替換讀取呼叫,用BarcodeWriter.CreateBarcode(data, encoding)替換寫入呼叫。靜態方法不需要實例管理。
從Google ML Kit條碼掃描遷移到IronBarcode需要更改多少程式碼?
大多數遷移會導致較少的程式碼行。授權樣板、實例構造函式和顯式格式配置被移除。核心讀/寫操作映射為較短的IronBarcode等價物,且結果物件更清晰。
遷移期間,我是否需要同時安裝Google ML Kit條碼掃描和IronBarcode?
不需要。大多數遷移是直接替換而不是並行操作。一次遷移一個服務類,替換NuGet引用,並更新實例化和API呼叫模式後再移動到下一個類。
IronBarcode的NuGet包名稱是什麼?
包名是'IronBarCode'(大寫B和C)。可以用'Install-Package IronBarCode'或'dotnet add package IronBarCode'安裝。程式碼中的using指令是'using IronBarCode;'。
IronBarcode是如何簡化Docker部署相較於Google ML Kit條碼掃描?
IronBarcode是沒有外部SDK文件或掛載許可配置的NuGet封裝。在Docker中,設置IRONBARCODE_LICENSE_KEY環境變數,包在啟動時處理許可驗證。
遷移後,IronBarcode會自動檢測所有條碼格式嗎?
是的。IronBarcode自動檢測所有支持的格式的符號學。不需要顯式的BarcodeTypes枚舉。如果格式已經知道並且性能很重要,BarcodeReaderOptions允許限制搜索空間作為優化。
IronBarcode是否可以不使用單獨的庫讀取PDF中的條碼?
可以。BarcodeReader.Read("document.pdf")原生處理PDF文件。結果包括每個條碼發現的頁碼、格式、值和置信度。不需要外部PDF渲染步驟。
IronBarcode如何處理並行條碼處理?
IronBarcode的靜態方法是無狀態且執行緒安全的。直接使用Parallel.ForEach遍歷文件列表,不需要每個執行緒的實例管理。BarcodeReaderOptions.MaxParallelThreads控制內部執行緒預算。
從Google ML Kit條碼掃描遷移到IronBarcode會改變哪些結果屬性?
常見的重命名:BarcodeValue變為Value,BarcodeType變為Format。IronBarcode結果還新增了Confidence和PageNumber。整個解決方案的搜索和替換可處理現有結果處理程式碼中的重新命名。
我如何在CI/CD管道中設置IronBarcode授權?
將IRONBARCODE_LICENSE_KEY作為管道機密儲存,在應用程式啟動程式碼中分配IronBarCode.License.LicenseKey。一個機密涵蓋所有環境,包括開發、測試、分期和生產。
IronBarcode是否支持生成帶有自定義樣式的QR碼?
支持。QRCodeWriter.CreateQrCode()支持通過ChangeBarCodeColor()自定義顏色,通過AddBrandLogo()嵌入logo,可配置錯誤校正級別,以及包括PNG、JPG、PDF和流在內的多種輸出格式。

