Configure MRZ Scanner
When developing with MRZScannerActivity, you can add configurations via the MRZScannerConfig class. This page will guide you on how to configure the settings.
Scan Document Type
Set the document type via APIs
Specifies the type of document to scan, such as ID cards or passports. It also improves the processing speed and the accuracy.
- Java
- Kotlin
MRZScannerConfig config = new MRZScannerConfig(); config.setDocumentType(EnumDocumentType.DT_PASSPORT);val config = MRZScannerConfig().apply { documentType = EnumDocumentType.DT_PASSPORT }
Setup a customized template file
A template file is a JSON file that includes a series of algorithm parameter settings. It is always used to customize the performance for different usage scenarios. Contact us to get a customized template for your scanner.
-
Add a Templates folder to the assets folder of your project at src\main\assets\Templates. Put your JSON file in the Templates folder.
-
Specify the template file via setTemplateFile
- Java
- Kotlin
MRZScannerConfig config = new MRZScannerConfig(); config.setTemplateFile("CustomizedTemplate.json");val config = MRZScannerConfig().apply { templateFile = "CustomizedTemplate.json" }
You can also use a JSON string as the template file.
Related APIs
Configure the UI Elements

MRZ Scanner UI Component
- Close button: Stop MRZ scanning and go back to the previous activity.
- Torch button: A clickable button that can turn on/off the torch.
- Java
- Kotlin
MRZScannerConfig config = new MRZScannerConfig(); config.setTorchButtonVisible(false); config.setGuideFrameVisible(false); config.setCloseButtonVisible(false);val config = MRZScannerConfig().apply { torchButtonVisible = false guideFrameVisible = false closeButtonVisible = false }
Related APIs
Beep
Let the app to trigger a beep sound when MRZ is scanned successfully.
- Java
- Kotlin
MRZScannerConfig config = new MRZScannerConfig(); config.setBeepEnabled(true);val config = MRZScannerConfig().apply { isBeepEnabled = true }
Related API
Further Customization
If you have other customization requirements on the MRZScanner component, you can modify it with the open source code on GitHub.