IRONSOFTWAREHOME
与其他组件比较

Barkoder SDK 与 IronBarcode:C# 条码库对比

Curtis Chau
Curtis Chau
Updated: 2026年4月26日

Dynamsoft 条形码阅读器在其设计用途方面确实非常出色:以每秒 30 帧的速度从实时摄像头画面中读取条形码。 算法速度快,符号支持范围广,而且在 iOS 和 Android 上封装它的移动 SDK 是该领域中较好的选择之一。 如果你的产品是一款仓库扫描应用程序,工人将手机对准托盘标签,并期望在 100 毫秒内完成识别,那么 Dynamsoft 是一个可靠的选择。

如果您的条形码在无法上网的服务器上的 PDF 文件中,该库与应用场景不匹配 —— 并且在您首次部署时许可证激活会提醒您。 LicenseManager.InitLicense 在首次激活时与Dynamsoft的许可证服务器进行在线握手,并定期重新验证。 在气隙数据中心、孤立的VPC或任何出站互联网访问受限的环境中,首次激活需要替代方法。线下路径——从Dynamsoft获取许可证内容blob并通过InitLicenseFromLicenseContent重放——可以工作,但增加了大多数文档处理工作流程没有预料到的操作负担。

此比较侧重于用例匹配度,而非库的质量。 Dynamsoft 构建了一个以相机为中心的库,并且构建得很好。 问题是,以摄像头为先的假设是否适用于服务器端文档处理工作流程。

了解 Dynamsoft 条码阅读器

Dynamsoft 的架构体现了其相机行业的渊源。 启动序列需要在线许可证激活,设置模型包含适合于实时帧处理的超时值,并且 API 公开了针对手持摄像头的可变焦点和运动模糊条件调优的设置:

// Dynamsoft: license activation required at startup
using Dynamsoft.CVR;
using Dynamsoft.DBR;
using Dynamsoft.License;
using Dynamsoft.Core;

// LicenseManager.InitLicense performs an online activation on first run
int errorCode = LicenseManager.InitLicense("YOUR-DYNAMSOFT-LICENSE-KEY", out string errorMsg);
if (errorCode != (int)EnumErrorCode.EC_OK)
    throw new InvalidOperationException($"License activation failed: {errorMsg}");

using var router = new CaptureVisionRouter();

// Settings tuned for camera frame processing
SimplifiedCaptureVisionSettings settings = router.GetSimplifiedSettings(
    PresetTemplate.PT_READ_BARCODES);
settings.BarcodeSettings.ExpectedBarcodesCount = 1; // single barcode per frame
settings.Timeout = 100;                              // 100ms suits a 30fps pipeline
router.UpdateSettings(PresetTemplate.PT_READ_BARCODES, settings);

这是一个设计精良的API,完全符合其用途。 Timeout = 100 设置在相机每秒处理30帧且不能花费500毫秒在单帧上时有意义。 对于处理上传 PDF 的服务器, 100ms 的超时时间没有用处,并可能导致在较密集条形码上读取失败。

路由器和会话设计——router.Dispose()——遵循相机会话语义:打开路由器,处理帧,处理结束。 对于文件处理而言,此生命周期增加了样板代码,却没有带来任何好处。

PDF问题

Dynamsoft Barcode Reader 可以在Windows构建中直接接受一些PDF输入,但对于跨平台部署,许多团队仍然在传递给CaptureVisionRouter.Capture之前预先将每个PDF页面渲染为图像。 这通常引入一个单独的 PDF 渲染库 — PdfiumViewer 是常用选项 — 这增加了一个 NuGet 依赖项,还有一个本地二进制依赖项(Windows上的 pdfium.dll 或 Linux上的 libpdfium),并围绕每次 PDF 操作产生一个渲染循环:

// Dynamsoft PDF processing — typical cross-platform pattern with PdfiumViewer
// dotnet add package PdfiumViewer
using PdfiumViewer;
using System.Drawing.Imaging;
using Dynamsoft.CVR;
using Dynamsoft.DBR;

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

    using (var pdfDoc = PdfDocument.Load(pdfPath))
    using (var router = new CaptureVisionRouter())
    {
        for (int page = 0; page < pdfDoc.PageCount; page++)
        {
            // Render each page at 300 DPI
            using var image = pdfDoc.Render(page, 300, 300, true);
            using var ms = new MemoryStream();
            image.Save(ms, ImageFormat.Png);
            byte[] imageBytes = ms.ToArray();

            // Now pass rendered image bytes to the Capture Vision Router
            CapturedResult result = router.Capture(imageBytes,
                PresetTemplate.PT_READ_BARCODES);
            foreach (var item in result.GetDecodedBarcodesResult().GetItems())
                results.Add(item.GetText());
        }
    }

    return results;
}

这就有了三个依赖项(Dynamsoft, PdfiumViewer 和不同平台的本地二进制),一个逐页渲染循环,以及随页数比例增加的内存开销。

IronBarcode可以直接读取 PDF 文件:

// IronBarcode: PDF is native — no extra library, no render loop
// NuGet: dotnet add package BarCode
var results = BarcodeReader.Read("invoice.pdf");
foreach (var result in results)
{
    Console.WriteLine($"{result.Format}: {result.Value}");
}

一个电话。 没有PDF渲染器。 无需逐页循环。无需针对特定平台的原生 PDF 支持二进制文件。

许可证复杂性

当服务器有互联网访问时,在线许可证激活是简单明了的。 当网络策略没有明确规定出站主机的允许范围时,或者当网络策略要求明确列出出站主机的允许范围时,验证失败的面积就会增大:

// Dynamsoft: error code pattern required
int errorCode = LicenseManager.InitLicense("YOUR-DYNAMSOFT-LICENSE-KEY", out string errorMsg);
if (errorCode != (int)EnumErrorCode.EC_OK)
{
    // Possible causes: network timeout, license server unreachable,
    // invalid key, expired key, activation quota exceeded, etc.
    throw new InvalidOperationException($"Dynamsoft license failed [{errorCode}]: {errorMsg}");
}

与 Dynamsoft 的离线许可是一个独立的工作流程。 在连接的机器上执行初始在线激活以获取许可证包,持久化,然后通过InitLicenseFromLicenseContent重放该包以激活离线机器。

// Dynamsoft offline license — replay a pre-fetched license bundle
int errorCode = LicenseManager.InitLicenseFromLicenseContent(
    licenseContent, out string errorMsg);
if (errorCode != (int)EnumErrorCode.EC_OK)
    throw new InvalidOperationException($"Offline activation failed: {errorMsg}");

这种方式获得的许可证包有一个过期窗口(通常为几天到一年)需要在其失效前进行刷新,这意味着不停地需要一个连网机器参与工作流。

IronBarcode许可证激活是本地评估的单次分配:

// IronBarCode: local validation, no network required
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

没有错误代码可供检查。 无需网络连接。 无许可证包刷新周期。 同一行适用于开发机器、CI/CD 管道、Docker 容器和气隙服务器。

相机与文件使用案例

Dynamsoft 和IronBarcode针对不同的主要方案进行优化。 下表描述了这一点而不是声称某个库普遍更好:

情景Dynamsoft 条码阅读器IronBarcode
实时摄像头画面(30帧/秒)针对实时进行优化并非主要用例
移动 SDK(iOS/Android)完整版 SDK 可用仅限.NET
服务器端文件处理通过 CaptureVisionRouter 支持主要用例
PDF条形码读取直接在 Windows 上; render loop common cross-platform本地支持
气隙部署需要离线许可证包工作流程开箱即用
Docker/临时容器每个环境的许可证包刷新单个环境变量
离线许可证来自先前在线激活的许可证内容包标准许可证密钥
ASP.NET Core API支持(额外的许可证样板)支持
Azure Functions首次激活的出站网络无需网络
条形码生成仅在 Barcode 阅读器包中读取是的——一代人与阅读
二维码生成不在 Barcode 阅读器包中是的——二维码写入器

了解IronBarcode

IronBarcode是一个用于生成和读取条形码的 .NET库。 该 API 是静态的——没有实例,没有释放调用,没有会话生命周期。 许可证激活在本地进行。 内置PDF支持:

// NuGet: dotnet add package BarCode
using IronBarCode;

// License — local validation, no network call
IronBarCode.License.LicenseKey = "YOUR-LICENSE-KEY";

// Read from an image file
var results = BarcodeReader.Read("label.png");
foreach (var result in results)
    Console.WriteLine($"{result.Format}: {result.Value}");

// Read from a PDF — native, no extra library
var pdfResults = BarcodeReader.Read("manifest.pdf");

// Read with options for high-accuracy or high-throughput scenarios
var options = new BarcodeReaderOptions
{
    Speed = ReadingSpeed.Balanced,
    ExpectMultipleBarcodes = true,
    最大并行线程数 = 4
};
var multiResults = BarcodeReader.Read("multi-barcode-sheet.png", options);
C#

生成过程同样简单明了:

// Generate Code 128
BarcodeWriter.CreateBarcode("SHIP-7734-X", BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng("shipping-label.png");

// Generate QR with error correction and embedded logo
QRCodeWriter.CreateQrCode("https://track.example.com/7734", 500, QRCodeWriter.QrErrorCorrectionLevel.Highest)
    .AddBrandLogo("company-logo.png")
    .SaveAsPng("tracking-qr.png");

// Get bytes for HTTP response
byte[] bytes = BarcodeWriter.CreateBarcode("ITEM-001", BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .ToPngBinaryData();

功能对比

特征Dynamsoft 条码阅读器IronBarcode
条形码读取是的——针对相机进行了优化是的——文件和文档优化
条形码生成
二维码生成是的——二维码写入器
原生 PDF 支持直接在 Windows 上; render loop common cross-platform是的——BarcodeReader.Read(pdf)
许可证验证在线激活 + 定期重新检查当地的
物理隔离/离线许可证内容包工作流程标准密钥,可离线使用
Docker/容器每个环境的许可证包工作流程单个环境变量
Azure Functions首次激活的出站网络无需网络
AWS-Lambda(AWS Lambda首次激活的出站网络无需网络
移动 SDKiOS 和 Android 版本均可用仅限.NET
实时摄像头(30fps)主要设计目标并非为此而设计
代码 128
二维码是的(阅读)是的(阅读和生成)
数据矩阵
PDF417
阿兹特克
EAN/UPC
实例管理new CaptureVisionRouter() + Dispose()静态 — 无实例
多条形码读取BarcodeSettings 上的 ExpectedBarcodesCountExpectMultipleBarcodes = true
阅读速度控制超时 + 模板调优阅读速度枚举
平行阅读手动穿线最大并行线程数
定价模式年度订阅 / 议定的永久许可永久 749 美元起
.NET支持.NET 6.0+ and .NET Framework 3.5+.NET 4.6.2 至.NET 9
平台Windows (x86/x64), Linux (x64)Windows、Linux、macOS、Docker、Azure、AWS Lambda

API 映射参考

对于拥有 Dynamsoft 代码且需要了解概念如何转换的团队:

Dynamsoft 条码阅读器IronBarcode
LicenseManager.InitLicense(key, out errorMsg)IronBarCode.License.LicenseKey = "key"
errorCode != (int)EnumErrorCode.EC_OK 检查不需要
LicenseManager.InitLicenseFromLicenseContent(content, out msg)不需要
new CaptureVisionRouter()静态 — 无实例
router.Dispose()不需要
router.Capture(imagePath, PresetTemplate.PT_READ_BARCODES)BarcodeReader.Read(imagePath)
router.Capture(imageBytes, PresetTemplate.PT_READ_BARCODES)BarcodeReader.Read(imageBytes)
BarcodeResultItem.GetText()result.Value
BarcodeResultItem.GetFormatString()result.Format
SimplifiedCaptureVisionSettings 通过 GetSimplifiedSettings()new BarcodeReaderOptions { ... }
settings.Timeout = 100Speed = ReadingSpeed.Balanced
settings.BarcodeSettings.ExpectedBarcodesCount = 1ExpectMultipleBarcodes = false (默认)
router.UpdateSettings(template, settings)作为参数传递给 Read()
外部 PDF 库 + 页面渲染循环BarcodeReader.Read("doc.pdf")

当球队切换

服务器端文档处理,而不是相机扫描。 最常见的迁移场景是一个团队基于声誉选择了Dynamsoft并集成了它,然后发现相机中心的API和PDF呈现步骤使文档处理工作流变得笨拙。 在网络应用中从上传的PDF读取条形码是一个核心用例,在Dynamsoft中需要额外的管道,但在IronBarcode中是单个调用。

**网络环境采用物理隔离或受限模式。**金融机构、医疗系统和政府机构通常会禁止应用服务器连接外部互联网。 Dynamsoft的在线激活在没有离线许可包工作流程的环境中无法运行,这增加了操作步骤。 这些环境中的团队经常迁移到IronBarcode,正是因为其许可证验证功能没有网络组件。

Docker和Kubernetes短暂容器。 实例频繁缩放的容器化部署使得重复许可包刷新管理变得笨拙。IronBarcode的许可证密钥作为标准环境变量使用,无需针对每个实例进行注册。

生成和读取的需求。 Dynamsoft Barcode Reader捆绑包为只读。 需要生成条形码标签、打印产品二维码或创建带有嵌入式条形码的运输清单的应用程序需要第二个库。 在这种情况下,团队通常会合并到IronBarcode,以避免管理两个独立的条形码依赖项。

简化的操作足迹。 从必须可达的外部依赖项列表中移除Dynamsoft许可服务器,移除PDF呈现库,并用静态调用替代路由器生命周期管理,减少了生产中可能出错的事情。

结论

Dynamsoft Barcode Reader是一款高质量库,非常适合其预期的用例:实时相机条形码扫描,尤其是在移动应用中。 这些算法针对手持扫描的条件进行了很好的调整——光照变化、运动模糊、部分遮挡。 如果你的使用场景符合这个条件,Dynamsoft 是一款很有竞争力的产品。

对于服务器端文档处理——从PDF中读取条形码,生成条形码标签,在气隙环境中运行,或在短暂的Docker容器中部署——该库的架构要求在每个步骤中进行更多设置。在线许可激活、跨平台PDF呈现模式、相机优化的超时设置和离线许可包工作流程是为移动相机使用而构建的后果。 它们不是虫子; 这是针对不同背景而刻意做出的设计选择。

IronBarcode是为文档和服务器端环境而设计的。 本地许可证验证、原生 PDF 阅读、静态 API 和生成支持都是一流的功能,而不是权宜之计。 决定取决于您的条形码实际所在的环境。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

...
阅读更多

相关文章

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 天试用密钥
无需信用卡或创建账户