Table of contents

MRZScanner

MRZScanner is the class that provides the ready-to-use MRZ scanning component. Its static Start method opens the scanner and returns the result.

Definition

Assembly: Dynamsoft.MRZScannerBundle.Maui

Namespace: Dynamsoft.MRZScannerBundle.Maui

public class MRZScanner

Methods

Method Description
Start Opens the MRZ scanner and returns the scan result when the scan ends.

Start

Opens the MRZ scanner full screen with the provided configuration and returns the result when the scan ends.

public static Task<MRZScanResult> Start(MRZScannerConfig config);

Parameter(s)

config: An MRZScannerConfig object that defines the scanner settings. Its License must be set.

Return Value

A task that completes with an MRZScanResult. Check its ResultStatus to tell whether the scan finished, was canceled, or failed. Scanning errors are reported through the result rather than thrown.

Remarks

  • Only one scanner is shown at a time. Calling Start while a scan is running, for example from a double tap, returns the running scan’s task.
  • On iOS, the scanner can’t open while another page is still animating, for example right after a PopModalAsync that wasn’t awaited. Start then returns an Exception result. See Starting the Scanner from a Modal Page.
  • On Android, the system can recreate the app’s page while the scanner is open. Start still completes, so keep the result outside the page. See Results and Image Lifetime.

How to Use

using Dynamsoft.MRZScannerBundle.Maui;

var config = new MRZScannerConfig("YOUR-LICENSE-KEY");
var result = await MRZScanner.Start(config);

switch (result.ResultStatus)
{
    case EnumResultStatus.Finished when result.Data is { } data:
        // Use the parsed fields, for example data.DocumentNumber.
        break;
    case EnumResultStatus.Canceled:
        // The user closed the scanner.
        break;
    case EnumResultStatus.Exception:
        // result.ErrorCode and result.ErrorString describe the failure.
        break;
}

This page is compatible for: