NEWSMRZ Scanner is now part of barKoder.What it means for you →

DOCUMENTATION

Hotelapp Sample (Cordova)

MRZ Scanner 1.x (archive)

Documentation / MRZ Scanner 1.x (archive)

 

Introduction

 

This is a sample application for using MRZ Scanner, the main purpose is to serve as a guide for implementing and using the library. It contains examples of the scanner practical integration.  

To skip this guide, go to the link below to be redirected to the downloading page.

https://mrzscanner.com/download

Sample Project:

https://github.com/Realmrzscanner/MRZScanner-SampleApp-Cordova

 

Implementation


Add the following code in your command line: $cordova plugin add../Desktop/MrzScanner. 

 

Usage


 1.We've defined our startScanner in a function along with setting a type for our scanner "0".

 

"0"-SCANNER_TYPE_MRZ

"1"-SCANNER_TYPE_DOC_IMAGE_ID,

"2"-SCANNER_TYPE_DOC_IMAGE_PASSPORT

 

function startScanner(){        
 MrzScanner.setScannerType([0],null, null);
 MrzScanner.startScanner(null,successfulScan,failedScan);
}

 

This function is called on a button click.

 

​
document.getElementById("startScanner").addEventListener("click", startScanner);

​

     

  2. startScanner returns a callback key "successfulMrzScan" with the results object. Further on we add the results in the input type tag for a display.

 

  
      function successfulScan(successfulMrzScan){
        
             document.getElementById("sunameTxt").value = successfulMrzScan.surname;
            
             document.getElementById("givenNameTxt").value = successfulMrzScan.given_names_readale;
            
             document.getElementById("documentNumberTxt").value = successfulMrzScan.document_number;
            
             document.getElementById("issuingCountryTxt").value = successfulMrzScan.issuing_country;
            
             document.getElementById("nationalityTxt").value = successfulMrzScan.nationality;
            
             document.getElementById("DOBTxt").value = successfulMrzScan.dob_readable;
            
             document.getElementById("sexTxt").value = successfulMrzScan.sex;
            
             document.getElementById("estimatedIDTxt").value = successfulMrzScan.est_issuing_date_eadable;
            
             document.getElementById("expirationDateTxt").value = successfulMrzScan.expiration_date_eadable;
            
             document.getElementById("optionalValueTxt").value = successfulMrzScan.optionals;
    
    }

 

                            Screenshot_20190726-125121_HotelApp.jpg   Screenshot_20190726-130156_HotelApp.jpg

 

3. In case of a failed scan, an alert will display a message.

 function failedScan(scanFailed){
        alert(scanFailed);
    }

 

4. Adding an ID image scan of the document by calling setScannerType to "1" and calling key successfulImageScan.
 

 function startScanner1(){
        MrzScanner.setScannerType([1],null, null);
        MrzScanner.startScanner(null,successfulImageScan,null);
    }

 

The image is received as a base64 string and it needs to decoded before displaying in a view
 

 function successfulImageScan(successfulScanWithDocumentImage){
        var image = document.getElementById("scanImage");
        image.img = "data:image/png;base64," + successfulScanWithDocumentImage;
    }

 

Updated Oct 24, 2026 · Questions? Ask us