PDFium Delphi Component Docs

Optional ZXing barcode backend

CreatePdfZXingBarcodeProvider provides an IPdfBarcodeProvider by loading a native bridge built from ZXing-C++ 2.3.0; supply its absolute path and ensure it matches the target

TryCreatePdfZXingBarcodeProvider diagnoses missing libraries or exports and incompatible bridge ABIs, leaving the process search path untouched

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 handed back by the backend

The generator produces Code128, QR, DataMatrix and PDF417 as black vector rectangles at the chosen module size; Code128 is limited to its supported character set, whilst the matrix formats accept Unicode text

QuietZoneModules leaves space above and to the left of the black rectangles; when placing or rasterising them, reserve a white quiet zone below and to the right as well

For recognition, supply top-down single-byte greyscale data together with width, height and stride; returned bounds are half-open pixel rectangles, and confidence 1 indicates an accepted decode rather than a statistical probability

TPdfZXingBarcodeOptions bounds the provider for its lifetime; values outside the finite limits fail creation with EPdfBarcodeBackendError rather than 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

The default allowances are 4,194,304 pixels, 32,768 bytes of UTF-8 text and 1,000,000 vector rectangles; the quiet zone is 4 and the error-correction level is 2

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

For QR, levels 0–2 mean L, 3–4 mean M, 5–6 mean Q and 7–8 mean H; PDF417 accepts 0–8, whilst Code128 and DataMatrix disregard this setting

A recognition call returns no more than 255 symbols, regardless of a larger requested limit; the existing provider interface does not expose a cancellation token

See Native/BarcodeZXing for building the bridge and Tests/BarcodeProvider for a runnable encoding/decoding example; this change includes neither bridge binaries nor dependency source

Actual Delphi/FPC Win32/Win64 runs pass 60 encoding/decoding round trips covering rotation, inversion and Unicode; the native Linux bridge passes 15 round trips, although the Pascal provider still depends on the wrapper's Windows facilities

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;