Customizing the MRZ Scanner
This page shows how to configure the MRZ Scanner through the MRZScannerConfig class.
MRZScannerConfig Overview
MRZScannerConfig carries almost every option the MRZ Scanner exposes. Create one, set the properties you need, and pass it to MRZScanner.Start(config). The scanner reads it when it starts, so a change takes effect on the next scan.
MRZScannerConfig contains the following properties:
License- the only property you must set; every other property has a working default. If the license is missing, invalid, or expired, the scanner shows an error telling the user to contact the app administrator.DocumentType(defaultEnumDocumentType.All) - the type of document to recognize:All,Id, orPassport. See Supported Document Types.TemplateFile(defaultnull) - a custom Capture Vision template, as an app asset name, a file path, or a JSON string. Contact the Dynamsoft Technical Support Team for help with templates.IsBeepEnabled(defaultfalse) - plays a beep on a successful scan.IsVibrateEnabled(defaultfalse) - vibrates the device on a successful scan.IsCloseButtonVisible(defaulttrue) - shows the button that closes the scanner.IsTorchButtonVisible(defaulttrue) - shows the flashlight toggle.IsCameraToggleButtonVisible(defaulttrue) - shows the front/rear camera toggle.IsBeepButtonVisible(defaulttrue) - shows the toggle that turns the beep on or off.IsVibrateButtonVisible(defaulttrue) - shows the toggle that turns vibration on or off.IsFormatSelectorVisible(defaulttrue) - shows the selector for ID cards, passports, or both.IsGuideFrameVisible(defaulttrue) - shows the guide frame. Hiding it also changes what is scanned; see Hiding the guide frame.ReturnDocumentImage(defaulttrue) - includes the cropped document images in the result.ReturnPortraitImage(defaulttrue) - includes the portrait in the result. It also drives two-sided scanning; see Scanning Two-Sided Documents.ReturnOriginalImage(defaultfalse) - includes the full camera frames in the result.IsCameraPermissionPromptEnabled(defaulttrue) - shows the scanner’s own prompt when camera access is unavailable; see Handling Camera Permission.
The sections below show these properties in use.
Setting the MRZ Document Type
Using the API
Restricting the document type improves processing speed and accuracy:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
config.DocumentType = EnumDocumentType.Passport;
Using a customized template file
A template is a JSON file of algorithm settings for specialized scenarios. It replaces the built-in templates, so DocumentType has no effect, and on iOS the format selector is hidden. Contact us to get a customized template.
- Add the template to your project’s Resources/Raw folder, so it’s bundled as a MAUI asset.
-
Pass its file name:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9"); config.TemplateFile = "CustomizedTemplate.json";
TemplateFilealso accepts a file path on the device, or the template’s JSON as a string.
Related APIs
Configure the UI Elements

MRZ Scanner UI
The MRZ Scanner UI includes the following configurable elements:
- Close button: closes the scanner and returns to the previous page.
- Torch button: turns the flashlight on or off for low light.
- Camera toggle button: switches between the front and rear cameras.
- Beep button: turns the success beep on or off.
- Vibrate button: turns the success vibration on or off.
- Prompt text: guides the user through each step of the scan.
- Guide frame: shows where to place the document.
- Format selector: chooses ID card, passport, or both.
The scanning spinner isn’t configurable; see The Scanner Screen for what it means.
All UI elements are visible by default. Hide the ones you don’t need:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
config.IsCloseButtonVisible = false;
config.IsTorchButtonVisible = false;
config.IsCameraToggleButtonVisible = false;
config.IsBeepButtonVisible = false;
config.IsVibrateButtonVisible = false;
config.IsFormatSelectorVisible = false;
config.IsGuideFrameVisible = false;
Hiding the guide frame
The guide frame defines the area the scanner reads, so hiding it changes behavior as well as appearance. With IsGuideFrameVisible = false:
- The whole camera preview is scanned, so a document elsewhere in the shot can be picked up.
- Each frame costs more to process, which raises CPU load and battery use.
- The prompt text is hidden too, since it’s a label on the frame.
- The spinner and the flip prompt remain, because the user still needs them.
Related APIs
IsCloseButtonVisibleIsTorchButtonVisibleIsCameraToggleButtonVisibleIsBeepButtonVisibleIsVibrateButtonVisibleIsFormatSelectorVisibleIsGuideFrameVisible
Enabling Haptic and Audio Feedback
The scanner can beep or vibrate on a successful scan. Both are off by default:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
config.IsBeepEnabled = true; // beep on a successful scan
config.IsVibrateEnabled = true; // vibrate on a successful scan
These set the starting behavior; users can still change it with the beep and vibrate buttons unless you hide them. On iOS the beep is a system sound, so the ringer’s silent mode mutes it.
Related APIs
Configure Scan Result Images
By default the result includes the cropped document images and the portrait. Turn off what you don’t need to save memory and processing:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
config.ReturnDocumentImage = true; // cropped document images (default: true)
config.ReturnPortraitImage = true; // portrait image (default: true)
config.ReturnOriginalImage = false; // full camera frames (default: false)
Read the images from the MRZScanResult with GetDocumentImage(EnumDocumentSide), GetOriginalImage(EnumDocumentSide), and GetPortraitImage(). See Results and Image Lifetime for converting them to a MAUI ImageSource.
Related APIs
ReturnDocumentImageReturnPortraitImageReturnOriginalImageGetDocumentImageGetOriginalImageGetPortraitImage
Handling Camera Permission
The scanner manages the camera permission for you and never opens the camera without access. On iOS, the only setup is the camera usage description.
If access is unavailable, the scanner explains the situation and offers what can resolve it:
| State | Scanner’s prompt |
|---|---|
| The user denied camera access | iOS: Open Settings. Android: Allow camera access while it can still be requested, otherwise Open Settings |
| Device policy restricts the camera | An explanation only; the user can’t change it |
If the scan ends without access, the outcome is reported as EnumResultStatus.Exception with an ErrorCode of CameraPermissionDenied (1001) or CameraPermissionRestricted (1002). On Android, the scan continues if the user grants access from the prompt, and only Cancel reports the denial.
On iOS, the system asks for camera access only once per install, and changing the permission in Settings terminates the app. A page that shows a denial should keep its own route into Settings. The ScanMRZ Demo App shows this.
Presenting your own permission UI
To replace the scanner’s prompt with your own, turn it off and read the error code:
var config = new MRZScannerConfig("DLS2eyJvcmdhbml6YXRpb25JRCI6IjIwMDAwMSJ9");
config.IsCameraPermissionPromptEnabled = false;
var result = await MRZScanner.Start(config);
if (result.ErrorCode == (int)EnumErrorCode.CameraPermissionDenied)
{
// Explain, and offer a button that calls AppInfo.ShowSettingsUI().
}
else if (result.ErrorCode == (int)EnumErrorCode.CameraPermissionRestricted)
{
// Explain that the camera is restricted; Settings can't change it.
}
The denial is still reported, and the camera still never starts without access.
Related APIs
Further Customization
If you have other customization requirements for the MRZScanner component, contact the Dynamsoft Support Team.