跳至页脚内容
与其他组件比较

LEADTOOLS 条形码库与 IronBarcode 对比:C# 条形码库比较

要在 Docker 中使用 LEADTOOLS 条形码,您需要将许可证文件挂载到容器的特定路径。 每次部署都必须携带该文件。 环境变量还不够。 每次部署 LEADTOOLS 都是一个文件管理问题。

这并非对 LEADTOOLS 工程技术的批评——它反映的是一种 30 年前设计的许可架构,该架构是在容器技术出现之前设计的。 但到了 2026 年,当你的 CI/CD 流水线需要构建并推送容器镜像时,你要么将 .LIC 文件嵌入到镜像中,要么在运行时将其挂载为卷。无论哪种方式,你的条形码库都需要在初始化之前访问文件系统。这就是本文要探讨的根本权衡。

了解 LEADTOOLS 条形码

LEADTOOLS 条码是 LEAD Technologies 综合文档影像 SDK 的一部分,该 SDK 自 1990 年以来一直在持续开发。条码模块支持 40 多种条码符号,并与更广泛的 LEADTOOLS 生态系统紧密集成,用于 OCR、表单处理、PDF 操作和图像查看。 当一个应用程序需要从单个供应商处获得所有这些功能时,这种生态系统集成就显得尤为重要。 当需要在独立的微服务或专用应用程序中进行条形码扫描时,同样的集成也会带来额外的开销,必须在每次部署中加以考虑。

图书馆的建筑风格反映了它的年代。 LEADTOOLS 的设计时代是明确的资源管理、手动配置和基于文件系统的许可模式。 这些设计决策在各自的背景下都是合理的。 在现代.NET开发中——容器化工作负载、CI/CD 管道、密钥管理系统——这些决策会造成团队必须积极克服的摩擦。

部署 LEADTOOLS 条形码至少需要五个NuGet包。PDF 条形码提取功能则需要第六个包。 在 Windows 系统上,主机上必须安装 MSVC++ 2017 运行时环境。LEADTOOLS 条形码应用程序的最终输出文件大小约为 148 MB。

LEADTOOLS 条形码的关键架构特征:

-基于文件的许可架构:需要一个 .LIC 文件物理存在于磁盘上的已知路径中,以及一个开发者密钥字符串。 库初始化时,这两者必须均可访问。 -两级许可模式:开发许可和部署许可分别定价和获取。 生产部署报价需要联系 LEADTOOLS 销售部门。 -多包安装:最小条形码安装需要 Leadtools.BarcodeLeadtoolsLeadtools.CodecsLeadtools.Codecs.PngLeadtools.Codecs.Jpeg。 每增加一种图像格式,就需要单独的编解码器包。 -本机运行时依赖项: Windows 部署除了.NET运行时之外,还需要 MSVC++ 2017 运行时。 -显式符号声明:条形码读取需要传递一个 BarcodeSymbology 枚举值数组,指定要扫描的格式。 省略的格式将无法被检测到。 -分层初始化序列:加载许可证文件后,应用程序必须验证许可证是否已过期,并且每个必需的功能(1D 读取、2D 读取、写入)是否已单独解锁,然后才能创建 BarcodeEngine。 -支持 40 多种符号体系:作为综合成像平台的一部分,对 1D 和 2D 条形码类型具有强大的格式覆盖范围。

基于文件的许可架构

LEADTOOLS 初始化大约需要 20 行代码,然后才能执行第一个条形码操作。 该序列涵盖文件路径解析、过期验证和每个功能的锁定检查:

// LEADTOOLS: 20行以上 before the first barcode operation
using Leadtools;
using Leadtools.Barcode;

RasterSupport.SetLicense(
    @"C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC",
    "your-developer-key-here");

if (RasterSupport.KernelExpired)
    throw new InvalidOperationException("LEADTOOLS license has expired");

if (RasterSupport.IsLocked(RasterSupportType.Barcode1DRead))
    throw new InvalidOperationException("1D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.Barcode2DRead))
    throw new InvalidOperationException("2D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.BarcodeWrite))
    throw new InvalidOperationException("Barcode writing is locked");

var engine = new BarcodeEngine();
// LEADTOOLS: 20行以上 before the first barcode operation
using Leadtools;
using Leadtools.Barcode;

RasterSupport.SetLicense(
    @"C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC",
    "your-developer-key-here");

if (RasterSupport.KernelExpired)
    throw new InvalidOperationException("LEADTOOLS license has expired");

if (RasterSupport.IsLocked(RasterSupportType.Barcode1DRead))
    throw new InvalidOperationException("1D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.Barcode2DRead))
    throw new InvalidOperationException("2D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.BarcodeWrite))
    throw new InvalidOperationException("Barcode writing is locked");

var engine = new BarcodeEngine();
Imports Leadtools
Imports Leadtools.Barcode

' LEADTOOLS: 20行以上 before the first barcode operation

RasterSupport.SetLicense("C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC", "your-developer-key-here")

If RasterSupport.KernelExpired Then
    Throw New InvalidOperationException("LEADTOOLS license has expired")
End If

If RasterSupport.IsLocked(RasterSupportType.Barcode1DRead) Then
    Throw New InvalidOperationException("1D barcode reading is locked")
End If

If RasterSupport.IsLocked(RasterSupportType.Barcode2DRead) Then
    Throw New InvalidOperationException("2D barcode reading is locked")
End If

If RasterSupport.IsLocked(RasterSupportType.BarcodeWrite) Then
    Throw New InvalidOperationException("Barcode writing is locked")
End If

Dim engine As New BarcodeEngine()
$vbLabelText   $csharpLabel

此初始化块必须成功执行,任何条形码读取或写入操作才能生效。 如果 .LIC 文件不存在、路径不正确或文件权限错误,LEADTOOLS 将不会初始化——不会静默地停止,而是会报错导致操作停止。

了解IronBarcode

IronBarcode是一个专注于.NET条形码的库,专门用于在.NET应用程序中读取和生成条形码。 IronBarcode并非大型成像 SDK 中的一个模块,而是以条形码功能为主要目的。 该库以单个NuGet包的形式分发,其中包含所有图像格式支持、原生 PDF 条形码提取和基于 ML 的错误纠正,而无需额外的编解码器包或原生运行时依赖项。

IronBarcode采用静态API设计。 BarcodeReaderBarcodeWriter 的静态方法调用提供了读写操作,无需创建实例或初始化对象。 许可证激活只需赋值一个字符串即可。 该库可自动检测所有 50 多种受支持的条码格式,无需在每次读取操作之前枚举预期格式。

该库面向.NET Standard 2.0 及更高版本,兼容.NET Framework 4.6.2+、. .NET 5、 .NET 6、 .NET 7、 .NET 8 和.NET 9。在任何受支持的操作系统上,都不需要特定于平台的本机运行时。

IronBarcode的主要特点:

-字符串密钥许可:许可证激活需要单个字符串赋值。 密钥可以来自环境变量、配置文件、密钥管理器或任何提供字符串值的来源。 -单个 NuGet 包:所有图像格式支持、PDF 提取和条形码功能都包含在 IronBarcode 中。 无需额外安装解码器包。 -静态 Fluent API: BarcodeReader.Read()BarcodeWriter.CreateBarcode() 是静态入口点。 无需创建引擎实例或编解码器对象。 -自动格式检测:可读取所有 50 多种受支持的符号体系,而无需调用者指定预期格式。 -内置 PDF 支持:基本软件包中包含 PDF 条形码提取功能,无需额外安装。 -支持 50 多种条码符号:涵盖所有主要的 1D 和 2D 条码格式,包括 Code 128、Code 39、QR Code、Data Matrix、PDF417、EAN-13 和 UPC-A。

  • ML 纠错:基于机器学习的图像纠错可提高对损坏或低质量条形码图像的读取准确率。

功能对比

下表列出了 LEADTOOLS 条码和IronBarcode之间的根本区别:

特征 LEADTOOLS 条形码 IronBarcode
许可模式 文件 + 密钥(双层) 仅限密钥(单层)
SDK占用空间 5 个以上软件包 + 原生运行时 1 包
初始化代码 20行以上 1 行
Docker部署 文件挂载要求 环境变量
PDF条形码提取 单独包装 内置
自动检测格式 有限的
总符号学 40岁以上 50岁以上
机器学习误差校正

详细功能对比

特征 LEADTOOLS 条形码 IronBarcode
许可
许可模式 文件 + 开发者密钥 仅字符串键
许可证等级 开发 + 部署(分开进行) 单一永久许可证
部署定价 联系销售 出版定价
环境变量中的许可证 部分(仅密钥,仍需文件)
许可证密钥管理器 文件仍需保留 是的(仅限字符串)
安装
需要NuGet包 5岁以上 1
原生运行时依赖项 MSVC++ 2017(Windows)
PDF 支持包 分开(Leadtools.Codecs.Pdf 包括
发布输出大小 约 148 MB 约 39 MB
阅读
一维符号体系 25岁以上 30+
二维符号系统 15岁以上 15岁以上
自动检测格式 有限的
需要明确声明符号体系
PDF条形码提取 是的(单独包装) 是的(内置)
机器学习误差校正
多条形码检测
一代
代码 128 生成
二维码生成
二维码标志品牌推广
流畅生成 API
输出格式 PNG、JPEG、BMP PNG、JPEG、BMP、SVG、HTML、PDF
API 设计
API 风格 遗留对象图 静态流畅
初始化行 20岁以上 1
图像加载层 栅格编解码器(单独) 自动翻译
平台
跨平台 部分(原生依赖项) 完整版(.NET Standard)
Docker/容器支持 文件挂载要求 环境变量
.NET Standard 2.0
.NET 8 / .NET 9

许可架构

对于部署到现代基础设施的团队来说,这两个库之间最重要的区别在于许可架构。

LEADTOOLS 方法

LEADTOOLS 许可要求文件系统中已知路径上存在一个 .LIC 文件,以及一个传递给 RasterSupport.SetLicense 的开发者密钥字符串。 调用 SetLicense 后,应用程序必须验证许可证是否已过期,并且每个条形码功能是否已单独解锁。 只有所有检查都通过后,才能创建 BarcodeEngine

// LEADTOOLS: 20行以上 before the first barcode operation
using Leadtools;
using Leadtools.Barcode;

RasterSupport.SetLicense(
    @"C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC",
    "your-developer-key-here");

if (RasterSupport.KernelExpired)
    throw new InvalidOperationException("LEADTOOLS license has expired");

if (RasterSupport.IsLocked(RasterSupportType.Barcode1DRead))
    throw new InvalidOperationException("1D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.Barcode2DRead))
    throw new InvalidOperationException("2D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.BarcodeWrite))
    throw new InvalidOperationException("Barcode writing is locked");

var engine = new BarcodeEngine();
// LEADTOOLS: 20行以上 before the first barcode operation
using Leadtools;
using Leadtools.Barcode;

RasterSupport.SetLicense(
    @"C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC",
    "your-developer-key-here");

if (RasterSupport.KernelExpired)
    throw new InvalidOperationException("LEADTOOLS license has expired");

if (RasterSupport.IsLocked(RasterSupportType.Barcode1DRead))
    throw new InvalidOperationException("1D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.Barcode2DRead))
    throw new InvalidOperationException("2D barcode reading is locked");

if (RasterSupport.IsLocked(RasterSupportType.BarcodeWrite))
    throw new InvalidOperationException("Barcode writing is locked");

var engine = new BarcodeEngine();
Imports Leadtools
Imports Leadtools.Barcode

' LEADTOOLS: 20行以上 before the first barcode operation

RasterSupport.SetLicense("C:\LEADTOOLS23\Support\Common\License\LEADTOOLS.LIC", "your-developer-key-here")

If RasterSupport.KernelExpired Then
    Throw New InvalidOperationException("LEADTOOLS license has expired")
End If

If RasterSupport.IsLocked(RasterSupportType.Barcode1DRead) Then
    Throw New InvalidOperationException("1D barcode reading is locked")
End If

If RasterSupport.IsLocked(RasterSupportType.Barcode2DRead) Then
    Throw New InvalidOperationException("2D barcode reading is locked")
End If

If RasterSupport.IsLocked(RasterSupportType.BarcodeWrite) Then
    Throw New InvalidOperationException("Barcode writing is locked")
End If

Dim engine As New BarcodeEngine()
$vbLabelText   $csharpLabel

这种基于文件的模型早于现代密钥管理系统。 必须在应用程序运行的每个环境中配置 .LIC 文件:开发人员机器、CI 构建代理、暂存服务器和生产主机。

IronBarcode方法

IronBarcode 的许可证初始化代码只有一行:

// IronBarcode: done
IronBarCode.License.LicenseKey = "YOUR-KEY";
// IronBarcode: done
IronBarCode.License.LicenseKey = "YOUR-KEY";
$vbLabelText   $csharpLabel

该密钥可以来自环境变量、配置文件或密钥管理器——任何可以产生字符串的地方。 无需查找文件,无需写入过期检查,也无需验证功能锁定。 对于许可证设置和部署选项,文档涵盖所有模式:环境变量、appsettings.json、Azure Key Vault 等。

Docker 和容器部署

编写 Dockerfile 时,许可证架构的差异就变得具体起来。

LEADTOOLS 方法

LEADTOOLS Docker 部署需要将 .LIC 文件复制到容器镜像中,或者在运行时将其挂载为卷:

FROM mcr.microsoft.com/dotnet/aspnet:8.0

WORKDIR /app
COPY publish/ .

# The license file must be physically present in the container
COPY LEADTOOLS.LIC /app/license/LEADTOOLS.LIC

ENV LEADTOOLS_LICENSE_PATH=/app/license/LEADTOOLS.LIC
ENV LEADTOOLS_DEVELOPER_KEY=your-developer-key

ENTRYPOINT ["dotnet", "YourApp.dll"]

这种方法会带来后续的并发症。 轮换或撤销许可证密钥需要重建映像或重新挂载卷。 CI/CD 流水线必须检入 .LIC 文件,或者在构建时从 base64 编码的密钥中解码该文件。原本设计用于存储键值对的 Kubernetes 密钥现在需要存储文件内容。 运行临时容器的团队必须解决每个新节点上的文件配置问题。

IronBarcode方法

IronBarcode不需要容器内的任何文件:

FROM mcr.microsoft.com/dotnet/aspnet:8.0

WORKDIR /app
COPY publish/ .

ENV IRONBARCODE_LICENSE=your-license-key

ENTRYPOINT ["dotnet", "YourApp.dll"]

环境变量模型原生支持 Docker secrets、Kubernetes secrets、AWS Secrets Manager、Azure Key Vault 和 HashiCorp Vault——任何可以将字符串注入容器环境的系统。 我们提供了一份完整的Docker 和 Linux 部署指南,涵盖 Alpine 和 Debian 基础镜像。

条形码读取

LEADTOOLS 方法

LEADTOOLS 读取需要创建一个 RasterCodecs 实例来加载图像,创建一个 BarcodeEngine 实例来扫描图像,以及一个 BarcodeSymbology 值的显式数组来指定要查找的格式。 如果数组中省略了某种条形码符号,则 LEADTOOLS 将无法检测到该类型的条形码:

// LEADTOOLS: codec, engine, explicit symbology list
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;

using var codecs = new RasterCodecs();
using var image = codecs.Load(imagePath);
var engine = new BarcodeEngine();

var symbologies = new[]
{
    BarcodeSymbology.Code128,
    BarcodeSymbology.QR,
    BarcodeSymbology.DataMatrix,
    BarcodeSymbology.EAN13,
    BarcodeSymbology.UPCA
};

var barcodes = engine.Reader.ReadBarcodes(
    image,
    LogicalRectangle.Empty,
    0,
    symbologies);

return barcodes.Select(b => b.Value).ToArray();
// LEADTOOLS: codec, engine, explicit symbology list
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;

using var codecs = new RasterCodecs();
using var image = codecs.Load(imagePath);
var engine = new BarcodeEngine();

var symbologies = new[]
{
    BarcodeSymbology.Code128,
    BarcodeSymbology.QR,
    BarcodeSymbology.DataMatrix,
    BarcodeSymbology.EAN13,
    BarcodeSymbology.UPCA
};

var barcodes = engine.Reader.ReadBarcodes(
    image,
    LogicalRectangle.Empty,
    0,
    symbologies);

return barcodes.Select(b => b.Value).ToArray();
Imports Leadtools
Imports Leadtools.Barcode
Imports Leadtools.Codecs

Dim barcodes As IEnumerable(Of BarcodeData)
Using codecs As New RasterCodecs()
    Using image As RasterImage = codecs.Load(imagePath)
        Dim engine As New BarcodeEngine()

        Dim symbologies As BarcodeSymbology() = {
            BarcodeSymbology.Code128,
            BarcodeSymbology.QR,
            BarcodeSymbology.DataMatrix,
            BarcodeSymbology.EAN13,
            BarcodeSymbology.UPCA
        }

        barcodes = engine.Reader.ReadBarcodes(
            image,
            LogicalRectangle.Empty,
            0,
            symbologies)
    End Using
End Using

Return barcodes.Select(Function(b) b.Value).ToArray()
$vbLabelText   $csharpLabel

IronBarcode方法

IronBarcode可自动检测所有 50 多种受支持的条码格式。 文件路径直接传递; 无需图像加载图层或符号系统数组:

// IronBarcode: auto-detect, no object setup
using IronBarCode;

var results = BarcodeReader.Read(imagePath);
return results.Select(r => r.Value).ToArray();
// IronBarcode: auto-detect, no object setup
using IronBarCode;

var results = BarcodeReader.Read(imagePath);
return results.Select(r => r.Value).ToArray();
Imports IronBarCode

Dim results = BarcodeReader.Read(imagePath)
Return results.Select(Function(r) r.Value).ToArray()
$vbLabelText   $csharpLabel

有关读取选项、调整速度与准确性以及处理复杂图像的更多详细信息,请参阅《从图像读取条形码指南》,其中涵盖了完整的 API 接口。

条形码生成

LEADTOOLS 方法

LEADTOOLS 条码生成需要创建一个 BarcodeData 对象,包含符号体系、值和边界 — 然后创建一个空白的 RasterImage 对象,包含明确的像素尺寸、位深度、字节顺序和视图透视 — 然后使用 FillCommand 对象填充白色背景 — 然后调用 engine.Writer.WriteBarcode() 对象 — 最后使用 RasterCodecs 对象保存。 这是针对多种对象类型的五种不同操作:

// LEADTOOLS: 5 operations, 25岁以上 lines
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;

var engine = new BarcodeEngine();

var barcodeData = new BarcodeData(BarcodeSymbology.Code128)
{
    Value = data,
    Bounds = new LeadRect(0, 0, 400, 100)
};

using var image = new RasterImage(
    RasterMemoryFlags.Conventional,
    400, 100, 24,
    RasterByteOrder.Bgr,
    RasterViewPerspective.TopLeft,
    null, IntPtr.Zero, 0);

new FillCommand(RasterColor.White).Run(image);
engine.Writer.WriteBarcode(image, barcodeData, null);

using var codecs = new RasterCodecs();
codecs.Save(image, outputPath, RasterImageFormat.Png, 0);
// LEADTOOLS: 5 operations, 25岁以上 lines
using Leadtools;
using Leadtools.Barcode;
using Leadtools.Codecs;

var engine = new BarcodeEngine();

var barcodeData = new BarcodeData(BarcodeSymbology.Code128)
{
    Value = data,
    Bounds = new LeadRect(0, 0, 400, 100)
};

using var image = new RasterImage(
    RasterMemoryFlags.Conventional,
    400, 100, 24,
    RasterByteOrder.Bgr,
    RasterViewPerspective.TopLeft,
    null, IntPtr.Zero, 0);

new FillCommand(RasterColor.White).Run(image);
engine.Writer.WriteBarcode(image, barcodeData, null);

using var codecs = new RasterCodecs();
codecs.Save(image, outputPath, RasterImageFormat.Png, 0);
Imports Leadtools
Imports Leadtools.Barcode
Imports Leadtools.Codecs

Dim engine As New BarcodeEngine()

Dim barcodeData As New BarcodeData(BarcodeSymbology.Code128) With {
    .Value = data,
    .Bounds = New LeadRect(0, 0, 400, 100)
}

Using image As New RasterImage(
    RasterMemoryFlags.Conventional,
    400, 100, 24,
    RasterByteOrder.Bgr,
    RasterViewPerspective.TopLeft,
    Nothing, IntPtr.Zero, 0)

    Dim fillCommand As New FillCommand(RasterColor.White)
    fillCommand.Run(image)
    engine.Writer.WriteBarcode(image, barcodeData, Nothing)

    Using codecs As New RasterCodecs()
        codecs.Save(image, outputPath, RasterImageFormat.Png, 0)
    End Using
End Using
$vbLabelText   $csharpLabel

IronBarcode方法

IronBarcode在内部处理图像创建、背景填充和编码:

// IronBarcode: one method chain
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(outputPath);
// IronBarcode: one method chain
BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128)
    .ResizeTo(400, 100)
    .SaveAsPng(outputPath);
Imports IronBarcode

BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) _
    .ResizeTo(400, 100) _
    .SaveAsPng(outputPath)
$vbLabelText   $csharpLabel

IronBarcode API 在创建条形码图像时,通过流畅的链式调用而非一系列命令式设置对象来公开样式、边距、旋转和格式转换。

API 映射参考

LEADTOOLS 条形码 IronBarcode 备注
RasterSupport.SetLicense(path, key) IronBarCode.License.LicenseKey = "key" 仅密钥——无文件
RasterSupport.KernelExpired (removed) 无需检查有效期
RasterSupport.IsLocked(RasterSupportType.Barcode1DRead) (removed) 所有功能包括
RasterSupport.IsLocked(RasterSupportType.Barcode2DRead) (removed) 所有功能包括
RasterSupport.IsLocked(RasterSupportType.BarcodeWrite) (removed) 所有功能包括
new BarcodeEngine() 静态 — 无实例 BarcodeReaderBarcodeWriter 是静态的
new RasterCodecs() (removed) 直接传递文件路径
codecs.Load(imagePath) (removed) 直接传递文件路径
engine.Reader.ReadBarcodes(image, rect, 0, symbologies) BarcodeReader.Read(imagePath) 自动检测符号体系
BarcodeData.Value result.Value 相同的属性名称
BarcodeData.Symbology result.Format 物业已更名
new BarcodeData(BarcodeSymbology.Code128) BarcodeWriter.CreateBarcode(data, BarcodeEncoding.Code128) 流畅的创作
BarcodeSymbology.Code128 BarcodeEncoding.Code128 命名空间更改
BarcodeSymbology.QR BarcodeEncoding.QRCode 更名
BarcodeSymbology.DataMatrix BarcodeEncoding.DataMatrix 同名
BarcodeSymbology.PDF417 BarcodeEncoding.PDF417 同名
BarcodeSymbology.EAN13 BarcodeEncoding.EAN13 同名
BarcodeSymbology.UPCA BarcodeEncoding.UPCA 同名
engine.Writer.WriteBarcode(image, data, null) + codecs.Save(...) .SaveAsPng(path) 一种方法链
new RasterImage(...) + new FillCommand(RasterColor.White).Run(image) (removed) IronBarcode内部

当团队考虑从 LEADTOOLS 条码迁移到IronBarcode时

容器和云部署

将工作负载迁移到 Docker、Kubernetes 或无服务器环境的团队会遇到基于文件的许可模式这一具体的运营问题。 每个新的容器实例、每个新的云区域和每个新的环境都必须在应用程序启动之前配置并可访问 .LIC 文件。 为字符串值密钥设计的密钥管理系统无法很好地处理基于文件的密钥。 已经将环境变量注入作为配置标准的团队发现,LEADTOOLS 需要一个单独的配置步骤,该步骤存在于他们正常的密钥工作流程之外。 当部署规模增长时——自动扩展、蓝绿部署、多区域复制——文件配置的运营成本也会随之增长。

SDK 占用空间和依赖项管理

当条形码读取或生成是服务的主要或唯一要求时,五包 LEADTOOLS 安装和 MSVC++ 2017 运行时依赖项会带来开销,影响容器镜像大小、无服务器函数中的冷启动延迟以及 CI/CD 管道中的构建时间。 构建轻量级微服务或 Lambda 式函数的团队发现,引入完整的图像 SDK 来解决条形码的特定需求会造成依赖关系,这在代码审查和架构审查中很难得到证明。 当未来的平台升级需要测试原生运行时依赖项变更时,这项工作将由维护服务的团队负责。

定价透明度

开发团队需要在开始开发之前制定项目预算,但无法从 LEADTOOLS 公布的价格中获得完整的成本信息。 开发许可证的价格为每位开发人员每年 1,295 美元至 1,469 美元,但服务器应用程序的生产部署许可证需通过销售部门单独报价。 一个由五名开发人员组成的团队,需要向三个生产服务器交付产品,他们必须先获得定制报价,才能确认 LEADTOOLS 是否符合他们的预算。 喜欢根据公布的价格做出采购决策的团队(比较各种方案、获得内部批准或制定多年预算)发现,这种模式需要在评估完成之前进行销售对话。

仅条形码要求

需要读取或生成条形码但不需要 OCR、DICOM 成像、文档注释或 LEADTOOLSSuite中的其他功能的应用程序,实际上是在为超出其需求范围的平台付费。 LEADTOOLS 的集成价值——即在其 OCR、条形码和文档处理模块之间传递数据的能力——是真实存在的,但只有当该Suite中的多个功能处于活跃使用状态时,它才能发挥作用。 当需求仅限于在 Web API 中扫描条形码或在文档处理流程中生成条形码时,一个专注于条形码的库可以直接满足需求,而无需承担综合成像平台的负担。

常见迁移注意事项

许可证初始化替换

整个 LEADTOOLS 初始化块(包括文件路径、过期检查和每个功能的锁定验证)都被替换为一行代码IronBarcode许可证密钥可以存储在任何存储字符串的密钥管理系统中:

// Replace the entire LEADTOOLS initialization block with:
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE");
// Replace the entire LEADTOOLS initialization block with:
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE");
' Replace the entire LEADTOOLS initialization block with:
IronBarCode.License.LicenseKey = Environment.GetEnvironmentVariable("IRONBARCODE_LICENSE")
$vbLabelText   $csharpLabel

Docker 环境变量模式

任何 Dockerfile 中的 COPY LEADTOOLS.LIC 行都将被完全删除。 许可证在运行时通过环境变量提供,可与所有标准密钥注入机制配合使用:

# Remove: COPY LEADTOOLS.LIC /app/license/LEADTOOLS.LIC
# Remove: ENV LEADTOOLS_LICENSE_PATH=/app/license/LEADTOOLS.LIC
# Add:
ENV IRONBARCODE_LICENSE=your-license-key

包裹移除

五个 LEADTOOLS 软件包(以及可选的 PDF 编解码器)被移除,并替换为一个单独的软件包:

dotnet remove package Leadtools.Barcode
dotnet remove package Leadtools
dotnet remove package Leadtools.Codecs
dotnet remove package Leadtools.Codecs.Png
dotnet remove package Leadtools.Codecs.Jpeg
# If added:
dotnet remove package Leadtools.Codecs.Pdf

dotnet add package IronBarcode
dotnet remove package Leadtools.Barcode
dotnet remove package Leadtools
dotnet remove package Leadtools.Codecs
dotnet remove package Leadtools.Codecs.Png
dotnet remove package Leadtools.Codecs.Jpeg
# If added:
dotnet remove package Leadtools.Codecs.Pdf

dotnet add package IronBarcode
SHELL

IronBarcode的其他功能

除了以上各节介绍的功能外, IronBarcode还提供以下与常见的.NET条形码应用场景相关的功能:

  • PDF 条形码提取从多页 PDF 文档中读取条形码,自动进行页面迭代,并对每个结果进行报告——无需页面循环。 -基于机器学习的错误纠正机器学习图像预处理无需额外配置即可提高对损坏、低对比度或旋转的条形码图像的读取准确率。 -异步批量处理 BarcodeReader.ReadAsync() 支持异步读取,从而实现高吞吐量批量处理,而不会阻塞线程。
  • QR 码 Logo 品牌 QRCodeWriter 支持通过一次方法调用将徽标图像嵌入 QR 码中心,并使用内置纠错功能来保持可扫描性。
  • SVG 和 HTML 输出 BarcodeWriter 除了光栅图像格式外,还可以将生成的条形码输出为可缩放的 SVG 文件或内联 HTML 元素。 -条形码读取器选项调整读取速度、预期符号提示、多条形码检测和图像预处理均可针对每次读取进行配置,而不会影响全局状态。

.NET兼容性和未来准备情况

IronBarcode面向.NET Standard 2.0,兼容.NET Framework 4.6.2 及更高版本、 .NET 5、 .NET 6、 .NET 7、 .NET 8 和.NET 9。该库没有特定于平台的本机运行时要求,无需额外的配置步骤即可部署在 Windows、Linux 和 macOS 上。 随着.NET 10 的普及,IronBarcode 的定期发布节奏确保了与当前和即将推出的.NET版本的兼容性。 静态 API 设计和单包分发模型在各个版本中保持稳定,因此版本升级不需要更改应用程序初始化代码或部署配置。

结论

LEADTOOLS 条形码和IronBarcode代表了.NET条形码库设计空间中的不同点。 LEADTOOLS 是一个拥有 30 年历史的综合图像 SDK 中的一个模块,它采用基于文件的许可架构、多软件包安装和反映其构建时代的工程规范的传统 API 设计。 IronBarcode是一个专为现代.NET构建的条形码库,采用单包安装、字符串密钥许可和静态 API,无需初始化对象。

当应用程序已经使用 LEADTOOLS 来实现其他功能(例如 OCR、DICOM 成像、文档注释或表单识别)时,LEADTOOLS 条形码是合适的选择。 在这些情况下,通过同一 SDK 添加条形码功能,无需引入新的供应商或新的许可关系,即可扩展现有投资。已与 LEADTOOLS 签订Enterprise协议的组织可能会发现,条形码功能的边际成本很低。对于真正需要 LEADTOOLS 成像平台全功能的应用而言,跨模块的集成价值是实实在在的。

当条形码读取或生成是服务的主要或唯一要求时,当应用程序部署到容器或云原生基础设施时,或者当团队需要在开始开发之前获得可预测的价格时, IronBarcode是合适的选择。 单包安装和环境变量许可模型与现代.NET服务的配置、部署和扩展方式相一致。 流畅的静态 API 减少了条形码功能所需的初始化和操作代码。

这两个库之间的实际差异在部署场景中体现得最为明显。 当团队添加新环境、扩展到新的云区域或轮换许可证凭证时, IronBarcode需要更新密钥管理器中的字符串。 LEADTOOLS 需要配置一个文件。这种区别并非对 LEADTOOLS 工程设计的批评,而是对每种架构所需功能的描述。 团队在进行客观评估时,应将该描述直接应用于自身的部署模型,并决定哪种模型更合适。

常见问题解答

什么是 LEADTOOLS 条形码?

LEADTOOLS Barcode 是一个 .NET 条形码库,用于在 C# 应用程序中生成和读取条形码。它是开发人员在为 .NET 项目选择条形码解决方案时评估的几个备选方案之一。

LEADTOOLS Barcode 和 IronBarcode 的主要区别是什么?

IronBarcode 使用静态、无状态的 API,无需实例管理,而 LEADTOOLS Barcode 通常需要在使用前创建和配置实例。IronBarcode 还提供原生 PDF 支持、自动格式检测以及跨所有环境的单密钥许可。

IronBarcode 的授权是否比 LEADTOOLS Barcode 更容易?

IronBarcode 使用单一许可证密钥,同时涵盖开发和生产部署。与将 SDK 密钥与运行时密钥分开的许可系统相比,这简化了 CI/CD 流水线和 Docker 配置。

IronBarcode 是否支持 LEADTOOLS Barcode 支持的所有条形码格式?

IronBarcode 支持超过 30 种条码符号体系,包括 QR 码、Code 128、Code 39、DataMatrix、PDF417、Aztec、EAN-13、UPC-A、GS1 等等。格式自动检测功能意味着无需显式枚举格式。

IronBarcode是否支持原生PDF条码读取?

是的。IronBarcode 可以直接从 PDF 文件中读取条形码,使用 `BarcodeReader.Read("document.pdf")` 方法,无需单独的 PDF 渲染库。每页的读取结果包括页码、条形码格式、数值和置信度评分。

与 LEADTOOLS Barcode 相比,IronBarcode 在批量处理方面有何不同?

IronBarcode 的静态方法是无状态的,并且天然线程安全,因此可以直接使用 Parallel.ForEach,而无需进行线程级实例管理。所有定价层级均无吞吐量上限。

IronBarcode支持哪些.NET版本?

IronBarcode 在单个 NuGet 包中支持 .NET Framework 4.6.2+、.NET Core 3.1 以及 .NET 5、6、7、8 和 9。平台目标包括 Windows x64/x86、Linux x64 和 macOS x64/ARM。

如何在.NET项目中安装IronBarcode?

通过 NuGet 安装 IronBarcode:在程序包管理器控制台中运行“Install-Package IronBarCode”,或在命令行界面中运行“dotnet add package IronBarCode”。无需其他 SDK 安装程序或运行时文件。

与 LEADTOOLS 不同,我可以在购买前评估 IronBarcode 吗?

是的。IronBarcode 的试用模式会返回完整的解码条形码值——只有生成的输出图像才会带有水印。您可以在购买前,用自己的文档测试读取准确率。

LEADTOOLS Barcode 和 IronBarcode 的价格有什么区别?

IronBarcode 的永久单开发者许可证起价为 749 美元,涵盖开发和生产环境。定价详情和批量许可选项请访问 IronBarcode 许可页面。无需单独的运行时许可证。

从 LEADTOOLS Barcode 迁移到 IronBarcode 是否简单?

从 LEADTOOLS Barcode 迁移到 IronBarcode 主要涉及将基于实例的 API 调用替换为 IronBarcode 的静态方法、移除许可相关的样板代码以及更新结果属性名称。大多数迁移都是减少代码,而不是增加代码。

IronBarcode 能生成带有 logo 的二维码吗?

是的。`QRCodeWriter.CreateQrCode().AddBrandLogo("logo.png")` 可以将品牌图片原生嵌入二维码中,并支持配置纠错功能。此外,它还支持通过 `ChangeBarCodeColor()` 函数创建彩色二维码。

Jordi Bardia
软件工程师
Jordi 最擅长 Python、C# 和 C++,当他不在 Iron Software 利用这些技能时,他就在游戏编程。分享产品测试、产品开发和研究的责任,Jordi 在持续的产品改进中增加了巨大的价值。多样的经验使他面临挑战并保持投入,他表示这是在 Iron Software 工作的最喜欢的方面之一。Jordi 在佛罗里达州迈阿密长大,并在佛罗里达大学学习计算机科学和统计学。

钢铁支援团队

我们每周 5 天,每天 24 小时在线。
聊天
电子邮件
打电话给我