CreatePdfZXingBarcodeProvider 通过明确指定的绝对路径加载与目标平台匹配的原生桥接库,提供 IPdfBarcodeProvider 实现;该桥接库基于 ZXing-C++ 2.3.0 构建
TryCreatePdfZXingBarcodeProvider 会报告库缺失、导出函数缺失或桥接 ABI 不兼容,不修改进程的搜索路径
生成支持 Code128、QR、DataMatrix 和 PDF417,返回按所需模块尺寸绘制的黑色矢量矩形;Code128 接受其支持的字符集,矩阵码支持 Unicode 文本
QuietZoneModules 将黑色矩形向右、向下偏移,为左侧和顶部留出静区;调用方在放置或栅格化结果时,还须在右侧和底部预留白色静区
识别输入为从上到下排列的单字节灰度数据,并明确指定宽度、高度和步长;边界采用半开像素矩形,confidence 1 表示解码已被接受,并非统计概率
默认预算为 4,194,304 像素、32,768 字节 UTF-8 文本和 1,000,000 个矢量矩形,静区为 4,纠错级别为 2
QR 纠错级别 0–2 对应 L,3–4 对应 M,5–6 对应 Q,7–8 对应 H;PDF417 使用 0–8,Code128 和 DataMatrix 忽略此选项
即使请求的上限更高,一次识别也最多返回 255 个符号;现有提供器接口没有取消令牌
构建说明和可运行的编码/解码示例见 Native/BarcodeZXing 和 Tests/BarcodeProvider;本次变更不附带原生桥接二进制或依赖源码
实际 Delphi/FPC Win32/Win64 执行通过了 60 次编码/解码往返测试,覆盖旋转、反色和 Unicode;原生 Linux 桥接执行通过了 15 次往返测试,但 Pascal 提供器仍受包装层的 Windows 依赖限制
Provider := CreatePdfZXingBarcodeProvider( BridgePath, TPdfZXingBarcodeOptions.Default); Rects := GeneratePdfBarcode(pbkQr, 'Invoice 12345', 2, Provider); Results := RecognisePdfBarcodes(Pixels, Width, Height, Stride, Provider, 256);
type
EPdfBarcodeBackendError = class(EPdfProduction);
TPdfZXingBarcodeOptions = record
MaxPixels: Int64;
MaxTextBytes: Integer;
MaxRectangles: Integer;
QuietZoneModules: Integer;
ErrorCorrectionLevel: Integer;
class function Default: TPdfZXingBarcodeOptions; static;
end;
// Recognition accepts top-down, one-byte grayscale pixels with explicit stride
// Bounds are half-open pixel rectangles; Confidence=1 denotes a valid decode
// The backend does not supply a statistical confidence estimate
// A recognition call returns at most 255 symbols, even with a higher requested limit
function CreatePdfZXingBarcodeProvider(const BridgeLibraryPath: string;
const Options: TPdfZXingBarcodeOptions): IPdfBarcodeProvider;
function TryCreatePdfZXingBarcodeProvider(const BridgeLibraryPath: string;
const Options: TPdfZXingBarcodeOptions; out Provider: IPdfBarcodeProvider;
out ErrorMessage: string): Boolean;