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
Startwhile 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
PopModalAsyncthat wasn’t awaited.Startthen returns anExceptionresult. See Starting the Scanner from a Modal Page. - On Android, the system can recreate the app’s page while the scanner is open.
Startstill 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;
}