IRONSOFTWAREHOME
影片

從Scandit SDK遷移到IronBarcode

Curtis Chau
Curtis Chau
Updated: 2026年8月1日

Scandit SDK是一個構建用於即時移動條碼檢測的相機掃描平台。 IronBarcode是一個針對.NET的伺服器端及基於文件的條碼處理程式庫。 這兩個程式庫服務於不同的主要用例,從一個遷移到另一個僅在特定情況下相關。

本指南涵蓋了使用Scandit的.NET套件處理文件、PDF或伺服器端文件流的團隊的遷移路徑——在這些場景中,Scandit的相機管道架構帶來阻力而非價值。 如果您的核心需求是用移動相機指向實體物件並接收帶有增強現實疊加的即時反饋,Scandit仍然是適當的工具,此指南不適用。 如果您的需求是從上傳的圖片中讀取條碼,從PDF文件中提取條碼資料,或在ASP.NET Core、Azure Functions、Docker容器或背景處理服務中運行條碼檢測,本指南提供一個完整的遷移路徑。

為什麼要從Scandit SDK遷移

**相機管道開銷:**每次Scandit整合都以相同的初始化序列開始,無論部署環境中是否存在相機:構建Camera實例、將其分配為幀源、將相機轉換為活動狀態並啟用條碼捕獲。 這一初始化存在是因為Scandit處理即時影片幀。 對於伺服器端文件處理,這一序列沒有任何好處,並引入了在目標環境中不存在的狀態複雜性——在Docker容器中沒有相機,在Azure Function中沒有幀源。

**沒有公開的價格:**Scandit不公開價格。 SparkScan、MatrixScan、ID Scanning、增強現實疊加和解析器是需分別詢價的單獨產品。 在進入銷售迴圈之前,無法完成預算提案、供應商比較或成本效益分析。 IronBarcode公佈了其價格——749美元、1499美元或2999美元的一次性永久購買——因此在開始寫程式碼之前就知道了這個數字。

**強制條碼型別聲明:**Scandit要求在掃描會話開始前顯式啟用每一種條碼格式。 在即時相機掃描中,這是一種性能優化——限制條碼型別減少了每個幀的處理開銷。 在基於文件的文件處理中,當接收的文件可能來自任何供應商或合作夥伴並攜帶任何條碼格式時,強制格式聲明成為一個限制。 枚舉每種可能的條碼型別既沒有性能優勢; 在圖書館頂層編寫格式猜測邏輯增加了工程負擔。

**不支持PDF:**在Scandit的API中沒有直接等價的BarcodeReader.Read("invoice.pdf")。 從PDF文件中提取條碼需要使用單獨的程式庫將每一頁渲染為光柵圖像,然後將這些渲染的圖像通過相機模擬管道。這種方法在文件處理工作流中需要額外的依賴性,額外的授權,以及巨大的工程努力。

基本問題

Scandit需要在任何條碼工作開始之前運行相機。 IronBarcode只需要一個文件路徑:

// Scandit SDK: mandatory camera pipeline before first barcode read
var dataCaptureContext = DataCaptureContext.ForLicenseKey("YOUR-SCANDIT-LICENSE");
var settings = BarcodeCaptureSettings.Create();
settings.EnableSymbologies(new HashSet<Symbology>
{
    Symbology.Ean13Upca,
    Symbology.Ean8,
    Symbology.Code128,
    Symbology.QrCode
});
var barcodeCapture = BarcodeCapture.Create(dataCaptureContext, settings);
var camera = Camera.GetDefaultCamera();
await dataCaptureContext.SetFrameSourceAsync(camera);
await camera.SwitchToDesiredStateAsync(FrameSourceState.On);
barcodeCapture.IsEnabled = true;
// Results arrive later via BarcodeScanned event callback
// IronBarcode: direct file reading
// NuGet: dotnet add package IronBarcode
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";
var results = BarcodeReader.Read("barcode.png");
foreach (var result in results)
    Console.WriteLine($"{result.Value} ({result.Format})");

整個相機管道塊——上下文建立、設置、條碼型別啟用、相機獲取、幀源分配、狀態轉換——被授權密鑰分配和一次方法調用所取代。

IronBarcode對比Scandit SDK:功能比較

功能Scandit SDKIronBarcode
主要部署移動相機掃描伺服器、雲端、桌面文件處理
需要相機
圖像文件讀取未設計為主要輸入型別
PDF條碼提取不支持本地多頁支持
流/字節陣列輸入不支持
自動格式檢測否(必須指定)是(預設行為)
事件驅動結果是(條碼掃描回調)否(同步返回)
ASP.NET Core/伺服器端未設計為完全支持
Azure Functions/無伺服器不實用完全支持
Docker / Linux不支持完全支持
條碼生成不支持包含在包中
多條碼檢測MatrixScan(單獨產品)包含在包中
定價模式聯繫銷售(每個產品)公佈的永久層級
每次掃描/每個裝置費用

快速開始

步驟 1:替換 NuGet 包

移除Scandit套件:

dotnet remove package Scandit.BarcodePicker
dotnet remove package Scandit.DataCapture.Core
dotnet remove package Scandit.DataCapture.Barcode
SHELL

安裝IronBarcode:

dotnet add package IronBarcode
SHELL

步驟 2:更新命名空間

將Scandit命名空間導入替換為IronBarcode命名空間:

// Before (Scandit SDK)
using Scandit.DataCapture.Core;
using Scandit.DataCapture.Barcode;
using Scandit.DataCapture.Barcode.Data;

// After (IronBarcode)
using IronBarCode;

步驟 3:初始化授權

在應用程式啟動時新增授權初始化,替換DataCaptureContext.ForLicenseKey呼叫:

// Before (Scandit SDK)
var dataCaptureContext = DataCaptureContext.ForLicenseKey("YOUR-SCANDIT-LICENSE");

// After (IronBarcode)
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

程式碼遷移範例

從圖片文件讀取條碼

處理靜態圖片文件是IronBarcode中支持的核心場景,而Scandit中不支持該工作流。 Scandit SDK處理實時相機幀; 讀取文件需要將捕捉流程適應為將位圖作為幀源,這無原生實現。

Scandit SDK 方法:

// Scandit SDK has no direct file-read API.
// Reading a static image requires constructing a bitmap frame source
// and routing it through the capture pipeline — an unsupported workaround.
// The standard Scandit integration assumes a running camera at all times.

IronBarcode 方法:

// NuGet: dotnet add package IronBarcode
using IronBarCode;

IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

var results = BarcodeReader.Read("product-label.png");
foreach (var result in results)
{
    Console.WriteLine($"Value: {result.Value}");
    Console.WriteLine($"Format: {result.Format}");
    Console.WriteLine($"Confidence: {result.Confidence}%");
}

從圖片中讀取條碼 使用IronBarcode不需要管道設置。結果集在方法返回後立即可用,無需事件訂閱。

從PDF文件中提取條碼

當從Scandit遷移時,PDF條碼提取是全新的領域,Scandit中不支持PDF。 IronBarcode直接讀取PDF文件,返回按頁碼索引的結果。

Scandit SDK 方法:

// Scandit SDK: no PDF support.
// Implementing PDF barcode extraction with Scandit requires:
// 1. A separate PDF rendering library to convert pages to raster images
// 2. Routing each rendered image through the camera simulation pipeline
// 3. Correlating results back to page numbers manually
// This is not a supported workflow and requires significant custom engineering.

IronBarcode 方法:

// NuGet: dotnet add package IronBarcode
using IronBarCode;

IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

var results = BarcodeReader.Read("shipping-manifest.pdf");
foreach (var result in results)
{
    Console.WriteLine($"Page {result.PageNumber}: {result.Value} ({result.Format})");
}

對於從PDF文件中讀取條碼的完整指導,包括頁面範圍選擇和多條碼處理,IronBarcode文件涵蓋了完整的PDF處理場景。 不需要額外的PDF程式庫依賴。

將事件回調轉換為直接返回值

Scandit通過BarcodeScanned事件提供條碼結果,因為即時相機掃描本質上是非同步的——當相機在當前幀中檢測到條碼時,結果才會到達。 IronBarcode返回結果作為型別化的集合,因為基於文件的讀取有一個已知的完成邊界。 這是遷移中結構上最有意義的變化之一。

Scandit SDK 方法:

// Scandit SDK: event-driven result delivery
barcodeCapture.BarcodeScanned += (sender, args) =>
{
    foreach (var barcode in args.Session.NewlyRecognizedBarcodes)
    {
        string value = barcode.Data;
        string symbology = barcode.Symbology.ToString();

        // Processing logic embedded inside event handler
        LogBarcodeResult(value, symbology);
        UpdateInventory(value);
    }
};

// Scan continues indefinitely until camera session is terminated

IronBarcode 方法:

// NuGet: dotnet add package IronBarcode
using IronBarCode;

IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

var results = BarcodeReader.Read("document.png");
foreach (var result in results)
{
    // Same processing logic, now in standard control flow
    LogBarcodeResult(result.Value, result.Format.ToString());
    UpdateInventory(result.Value);
}

所有內嵌在事件處理程式回調中的處理邏輯都移入標準的順序程式碼中。 錯誤處理、記錄和下游操作可使用普通的控制流程結構,而不是事件處理程式模式。

ASP.NET Core文件上傳端點

一個無狀態的伺服器端點從上傳的文件中讀取條碼,代表IronBarcode的主要伺服器端用例。 這一模式不支持Scandit的相機管道架構。

Scandit SDK 方法:

// Scandit SDK: not applicable to ASP.NET Core file upload scenarios.
// The DataCaptureContext requires a camera hardware session.
// There is no mechanism to process an IFormFile through the Scandit pipeline
// without substantial custom camera-simulation infrastructure.

IronBarcode 方法:

// NuGet: dotnet add package IronBarcode
using IronBarCode;

[ApiController]
[Route("api/[controller]")]
public class BarcodeController : ControllerBase
{
    [HttpPost("scan")]
    public IActionResult ScanUploadedDocument(IFormFile file)
    {
        if (file == null || file.Length == 0)
            return BadRequest("No file provided");

        using var stream = file.OpenReadStream();
        var results = BarcodeReader.Read(stream);

        if (!results.Any())
            return NotFound("No barcodes detected");

        return Ok(results.Select(r => new
        {
            r.Value,
            Format = r.Format.ToString(),
            r.PageNumber
        }));
    }
}

IFormFile.OpenReadStream(),不需要臨時文件建立。 結果在請求-響應迴圈中同步返回,無需非同步相機管理。

跨多文件的並發批處理

高容量文件隊列需要在多執行緒間進行並行處理。 由於IronBarcode的API是無狀態的,它本質上是執行緒安全的,並可以直接組合與Parallel.ForEach和非同步任務模式。

Scandit SDK 方法:

// Scandit SDK: no supported batch file processing pattern.
// The FrameSourceState model assumes a continuous camera session,
// not a queue of discrete documents. Batch processing would require
// one camera simulation pipeline per document or serialized processing
// through a shared pipeline — neither is a supported workflow.

IronBarcode 方法:

// NuGet: dotnet add package IronBarcode
using IronBarCode;
using System.Collections.Concurrent;

IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

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

var files = Directory.GetFiles("./documents/", "*.pdf");
var allResults = new ConcurrentBag<(string File, BarcodeResult Result)>();

Parallel.ForEach(files, file =>
{
    var results = BarcodeReader.Read(file, options);
    foreach (var result in results)
        allResults.Add((file, result));
});

foreach (var (file, result) in allResults)
    Console.WriteLine($"{Path.GetFileName(file)}: {result.Value} ({result.Format})");

對於涵蓋非同步和多執行緒條碼讀取的高級模式,包括吞吐量調整和執行緒數配置,IronBarcode文件提供詳細指導。

Scandit SDK API到IronBarcode的映射參考

Scandit SDKIronBarcode注意事項
DataCaptureContext.ForLicenseKey("key")IronBarCode.License.LicenseKey = "key"一次分配; 無上下文物件
BarcodeCaptureSettings.Create()new BarcodeReaderOptions()可選; 基本讀取不需要
settings.EnableSymbologies(Symbology.Code128, ...)(not needed)IronBarcode自動檢測所有格式
Camera.GetDefaultCamera()(not applicable)無相機概念
dataCaptureContext.SetFrameSourceAsync(camera)(not applicable)無幀源
camera.SwitchToDesiredStateAsync(FrameSourceState.On)(not applicable)無相機狀態機
barcodeCapture.IsEnabled = trueBarcodeReader.Read(path)單次調用啟動讀取
BarcodeScanned +=事件處理程式標準foreach over return value不需要事件系統
args.Session.NewlyRecognizedBarcodesBarcodeReader.Read()的返回值直接集合
barcode.Dataresult.Value相同的語義內容
barcode.Symbologyresult.Format等效格式枚舉
using Scandit.DataCapture.Coreusing IronBarCode單一命名空間
using Scandit.DataCapture.Barcodeusing IronBarCode包含在同一命名空間中
SparkScan產品BarcodeReader.Read(path)無需單獨產品
MatrixScan產品BarcodeReaderOptions { ExpectMultipleBarcodes = true }包含在基本包中

常見遷移問題及解決方案

問題1:相機管道程式碼沒有直接翻譯

Scandit SDK:DataCaptureContext, BarcodeCaptureSettings, BarcodeCapture設置塊跨7-10行的初始化程式碼,帶有非同步狀態轉換。

**解決方案:**完全刪除此塊。 它在IronBarcode中沒有對應,因為IronBarcode的基於文件的API不需要會話初始化。 用以下內容替換整個塊:

IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

問題2:BarcodeScanned事件處理程式邏輯

**Scandit SDK:**處理邏輯嵌入在BarcodeScanned +=事件處理程式lambda或方法中。 這一模式在IronBarcode中不存在。

**解決方案:**將處理程式主體移入標準程式碼,在BarcodeReader.Read調用之後:

// Before: event handler
barcodeCapture.BarcodeScanned += (s, args) =>
{
    foreach (var b in args.Session.NewlyRecognizedBarcodes)
        Console.WriteLine(b.Data);
};

// After: direct iteration
foreach (var result in BarcodeReader.Read("document.png"))
    Console.WriteLine(result.Value);

問題3:EnableSymbologies在程式碼庫中分散的調用

**Scandit SDK:**程式碼庫中的多個地方可能會因不同的掃描上下文而調用settings.EnableSymbologies(...)異同的條碼型別集合。

**解決方案:**移除所有EnableSymbologies調用。 IronBarcode預設下自動檢測所有支持的格式。 如果為特定場景中的性能需要限制格式,使用BarcodeReaderOptions.ExpectBarcodeTypes

var options = new BarcodeReaderOptions
{
    ExpectBarcodeTypes = BarcodeEncoding.Code128 | BarcodeEncoding.QRCode
};
var results = BarcodeReader.Read("document.png", options);

問題4:現有程式碼庫中無PDF讀取

**Scandit SDK:**如果現有程式碼庫在將PDF頁面轉換為圖像輸入到Scandit管道之前進行,則此自定義渲染基礎結構不再需要。

**解決方案:**完全移除PDF轉圖像的渲染步驟。 將PDF路徑直接傳遞給IronBarcode:

// Before: render PDF pages to images, then pass each image to Scandit pipeline
// (multiple steps, external PDF library dependency)

// After: pass PDF directly to IronBarcode
var results = BarcodeReader.Read("document.pdf");
// Results include PageNumber property for each detected barcode

問題5:非同步相機初始化模式

**Scandit SDK:**相機初始化使用SwitchToDesiredStateAsync。 如果調用程式碼依賴於這些非同步操作的結構,刪除它們簡化了非同步鏈。

**解決方案:**完全移除非同步相機初始化。 BarcodeReader.Read是同步的。 如果在UI或伺服器上下文中需要非同步執行以提高響應性,將其包裹在Task.Run

// Async wrapper for non-blocking execution
var results = await Task.Run(() => BarcodeReader.Read("document.png"));

Scandit SDK遷移清單

遷移前任務

審核程式碼庫中所有Scandit整合點:

grep -r "DataCaptureContext\|BarcodeCaptureSettings\|BarcodeCapture" --include="*.cs" .
grep -r "EnableSymbologies\|BarcodeScanned\|NewlyRecognizedBarcodes" --include="*.cs" .
grep -r "using Scandit" --include="*.cs" .
grep -r "barcode\.Data\|barcode\.Symbology\|FrameSourceState" --include="*.cs" .
SHELL

記錄所有掃描上下文——確定哪些程式碼路徑處理即時相機掃描(仍使用Scandit),哪些處理文件或文件處理(遷移到IronBarcode)。 注意在Scandit處理之前渲染的所有PDF頁面的地方,因為該渲染步驟將被淘汰。

程式碼更新任務

  1. 移除Scandit NuGet套件(Scandit.BarcodePicker, Scandit.DataCapture.Core, Scandit.DataCapture.Barcode
  2. 安裝IronBarcode NuGet套件
  3. using Scandit.DataCapture.*導入
  4. 完全刪除DataCaptureContext初始化塊
  5. 刪除所有SetFrameSourceAsync調用
  6. 刪除所有EnableSymbologies調用
  7. barcodeCapture.IsEnabled = true
  8. foreach over BarcodeReader.Read()結果
  9. barcode.Data
  10. barcode.Symbology
  11. 移除PDF轉圖像渲染管道現在IronBarcode直接讀取PDF
  12. 在應用程式啟動時新增IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY"

遷移後測試

在完成程式碼更新後驗證以下內容:

  • 確認IronBarcode返回的條碼值匹配同一輸入文件之前由Scandit返回的值
  • 驗證文件集中所有支持的條碼格式無需ExpectBarcodeTypes配置即可被檢測到
  • 測試PDF提取返回正確的PageNumber值多頁文件
  • 在預期負載下確認ASP.NET Core端點在可接受的響應時間內返回結果
  • 驗證Docker或容器化部署在無相機硬體的情況下成功完成條碼讀取
  • 測試並發批處理使用Parallel.ForEach在無競賽條件下生成正確的結果
  • 確認應用程式在IronBarcode授權密鑰替代Scandit上下文的情況下正確啟動和初始化

遷移到IronBarcode的主要優勢

**消除相機管道開銷:**移除DataCaptureContext初始化序列消除了狀態相機管理、非同步狀態轉換和平台特定相機API從伺服器端程式碼中。 結果程式碼更簡單、更短,沒有帶有平台限制,這些限制無法在Linux上部署,在Docker容器中,或在無伺服器計算環境中。

**直接PDF處理:**原生PDF條碼提取消除了對單獨PDF渲染程式庫的依賴,頁面到圖像之間的工程開銷,和該依賴的額外授權成本。 多頁PDF文件通過單次方法調用處理,頁面索引結果立即可用。

**同步無狀態API:**直接返回值模式替換事件驅動的回調模式為標準順序程式碼。 錯誤處理、記錄和下游處理自然與現有應用程式架構整合,不需要事件訂閱管理或非同步狀態機協調。

**公開透明的定價:**公佈的永久授權層次為749美元、1499美元和2999美元,允許預算提案、供應商比較和採購流程不需經過銷售迴圈。 在編寫整合程式碼之前即可確定授權成本。

**全雲端和容器支持:**IronBarcode的無狀態、硬體獨立API在Azure Functions,AWS Lambda,Docker容器上的Linux以及任何其他具有.NET運行時的計算環境中無需修改即可運行。 不需要相機模擬,無硬體依賴性解決方法和無平台特定配置即可在這些環境中部署。

**自動格式檢測:**移除EnableSymbologies聲明意味著攜帶意外條碼格式的輸入文件可以正確處理,無需程式碼更改。 當輸入文件中包含的格式集發生更改時——新的供應商,新的標籤格式,新的文件型別——IronBarcode會自動處理新格式。

請注意: Scandit是其各自擁有者的註冊商標。 本網站與Scandit無關,未獲Scandit認可或贊助。 所有產品名稱、標誌和品牌均為其各自所有者的財產。 比較僅供資訊參考,並反映了撰寫時公開可用的資訊。
Curtis Chau
技術作家

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

...
閱讀更多

相關文章

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預訂您的免費即時演示
Booking Badge

全球數百萬工程師信賴

Iron Software的客戶標誌
獲取您的無義務諮詢
完成下方表單或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
全球數百萬工程師信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立