PDFium Delphi Component Docs

Optional ZXing barcode provider

CreatePdfZXingBarcodeProvider supplies an IPdfBarcodeProvider using an explicit absolute path to a target-matched native bridge built from ZXing-C++ 2.3.0

TryCreatePdfZXingBarcodeProvider reports missing libraries, exports or incompatible bridge ABI without changing the process search path

EPdfBarcodeBackendError descends from EPdfProduction and is raised for every backend failure: a missing bridge library or export, an unsupported ABI version, options outside their finite limits, exhausted budgets, and invalid text or geometry returned by the backend

Generation supports Code128, QR, DataMatrix and PDF417 and returns black vector rectangles in the requested module size; Code128 accepts its supported character set while matrix codes support Unicode text

QuietZoneModules offsets black rectangles on the left and top; callers must also reserve a white quiet zone on the right and bottom when placing or rasterizing the result

Recognition accepts top-down one-byte grayscale bytes, explicit width, height and stride; bounds are half-open pixel rectangles and confidence 1 means an accepted decode rather than a statistical probability

TPdfZXingBarcodeOptions bounds the provider for its lifetime; values outside the finite limits fail creation with EPdfBarcodeBackendError instead of forwarding unbounded work to the native bridge

MaxPixels caps generated barcode images and recognition input at 4,194,304 width-times-height pixels at most, and larger images raise EPdfBarcodeBackendError

MaxTextBytes caps the UTF-8 payload at 32,768 bytes for both generation input and each decoded recognition result

MaxRectangles caps the vector rectangles one generation call can emit at 1,000,000; a barcode that would need more raises EPdfBarcodeBackendError

Default budgets are 4,194,304 pixels, 32,768 UTF-8 text bytes and 1,000,000 vector rectangles, with quiet zone 4 and error-correction level 2

ErrorCorrectionLevel selects the generator error-correction strength from 0 to 8 and is validated at provider creation

QR error-correction levels 0–2 select L, 3–4 M, 5–6 Q and 7–8 H; PDF417 uses levels 0–8; Code128 and DataMatrix ignore this option

Recognition returns at most 255 symbols even when the requested maximum is higher; the existing provider interface has no cancellation token

Build instructions and the runnable encode/decode example are in Native/BarcodeZXing and Tests/BarcodeProvider; no native bridge binary or dependency source is bundled by this change

Real Delphi/FPC Win32/Win64 execution passes 60 encode/decode round trips, including rotation, inversion and Unicode; native Linux bridge execution passes 15 round trips, while the Pascal provider remains subject to the wrapper's Windows dependencies

Provider := CreatePdfZXingBarcodeProvider(
  BridgePath, TPdfZXingBarcodeOptions.Default);
Rects := GeneratePdfBarcode(pbkQr, 'Invoice 12345', 2, Provider);
Results := RecognisePdfBarcodes(Pixels, Width, Height, Stride, Provider, 256);

Public declarations

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;