Scan Result Handling

This page explains the structure of scan results, how to access result data and images, and best practices for result handling.

Result Structure

The SDK delivers scan results as WrapperSessionScanResultsResponse objects through the onScanResults event stream. Each response contains an array of ExportedScanResult objects, the structured representation of what the scanner detected, including the recognized data, confidence score, and optionally captured images.

Top-Level Fields

Field Type Description

exportedScanResults

List

Array of ExportedScanResult objects, one per detected item

scanResultConfig

Object

The result configuration that was active during scanning

scanResultExtraInfo

Object

Additional metadata about the scan results

ExportedScanResult Fields

Each ExportedScanResult in the exportedScanResults array contains:

Field Type Description

pluginResult

Object

The plugin-specific scan result (contains pluginID, confidence, and result data per plugin type)

imageContainer

Object

Image delivery container with encoded (Base64) and/or saved (file paths) sub-objects

imageParameters

Object

Image format and quality settings used for export

The pluginResult structure varies by plugin type. See PluginResult Documentation for the full schema definition.

Receiving Results

Subscribe to the onScanResults event stream to receive results. The listener below demonstrates iterating over results and handling images:

  • Cordova

Scan results are delivered through the callbacks object passed to requestScanStart:

anylineInfinity.requestScanStart(
  request,
  onScanResponse,
  {
    onScanResults: function(result) {
      // Iterate over all results in this batch (may contain multiple when using composite scanning)
      var scanResults = result.exportedScanResults || [];
      scanResults.forEach(function(scanResult) {
        var pluginResult = scanResult.pluginResult;
        console.log('Plugin result:', pluginResult);

        // Handle images based on delivery method
        var imageContainer = scanResult.imageContainer;
        if (imageContainer && imageContainer.saved) {
          var saved = imageContainer.saved;
          var basePath = saved.path || '';
          var fullFramePath = basePath + '/' + (saved.images && saved.images.image);
          var cutoutPath = basePath + '/' + (saved.images && saved.images.cutoutImage);
        } else if (imageContainer && imageContainer.encoded) {
          var encoded = imageContainer.encoded;
          // Decode from Base64 for display or upload
          var fullFrameBase64 = encoded.images && encoded.images.image;
          var cutoutBase64 = encoded.images && encoded.images.cutoutImage;
        }
      });
    },
  }
);
In Cordova, scan result events are multiplexed through the same cordova.exec channel as the scan response. The plugin demultiplexes them automatically.

Image Handling

Scan results may include captured images, delivered via the imageContainer field on each ExportedScanResult. Images can be delivered as:

  • Encoded images (imageContainer.encoded): Base64-encoded image data embedded in the result

  • Saved images (imageContainer.saved): file paths to images saved on disk, with a path field for the directory and images for the filenames

Configure image delivery via scanResultConfig.imageContainer in the WrapperSessionScanStartRequest.

Session End Response

When a scan session ends (via requestScanStop, user dismissal, or error), requestScanStart resolves with a WrapperSessionScanResponse. This response contains:

  • status: indicates how the session ended (scanSucceeded, scanAborted, or scanFailed)

  • succeedInfo: populated when status is scanSucceeded

  • abortInfo: populated when status is scanAborted, contains the abort reason

  • failInfo: populated when status is scanFailed, contains the error details

  • scanResultConfig: the result configuration that was active during the session

Best Practices

  • In Cordova, callbacks are automatically scoped to the scan session

Next Steps