cordova-plugin-documentreader-mrz

4.2.1 • Public • Published

cordova-plugin-documentreader-mrz

Cordova plugin for reading and validation of identification documents. Using Regula Document Reader with MRZ Core inside for iOS version.

Install

Install plugn:

cordova plugin add cordova-plugin-documentreader-mrz --variable CAMERA_USAGE_DESCRIPTION="To take photo" --save

Usage

You can get trial license for demo application at licensing.regulaforensics.com (regula.license file).

InitializeReader:

DocumentReader.initReader(
    license,
    function (result) {
        // result will contain array of json results.
    },
    function (error) {
        alert(error);
    }
);

ScanDocument:

DocumentReader.scanDocument(
    function (result) {
        // result will contain array of json results.
    },
    function (error) {
        alert(error);
    }
);

How to build demo application

  1. Open terminal inside empty folder and run cordova create testdocumentreader <YOUR_APPLICATION_ID> DocumentReaderTest
  2. Run cd testdocumentreader
  3. Add plugin: cordova plugin add cordova-plugin-documentreader-mrz --variable CAMERA_USAGE_DESCRIPTION="To take photo" --save
  4. Add cordova-plugin-file for get license file: cordova plugin add cordova-plugin-file --save
  5. Get trial license for demo application at licensing.regulaforensics.com (regula.license file). When you will create license use <YOUR_APPLICATION_ID> like bundle ID (see the first paragraph).
  6. Put license to www/regula.license.
  7. Put this code inside onDeviceReady method file index.js (path: www/js/index.js) for calling DocumentReader plugin:
var app = {
    
    ...
    
    onDeviceReady: function() {
        this.receivedEvent('deviceready');
 
        window.resolveLocalFileSystemURL(
            cordova.file.applicationDirectory + "www/regula.license",
            this.onInitFileEntry,
            function(e) {
                console.log("FileSystem Error");
                console.dir(e);
            });
    },
    
    onInitFileEntry: function(fileEntry) {
        fileEntry.file(function(file) {
                var reader = new FileReader();
                reader.onloadend = function(e) {
                    app.onFileLoaded(this.result)
                }
                reader.readAsArrayBuffer(file);
            });
    },
        
    onFileLoaded: function(fileResult) {
        DocumentReader.initReader(
                fileResult,
                this.onDocReaderReady,
                function (error) {
                    alert(error);
                }
            );
    },
    
    onDocReaderReady: function(message) {
     // set scenarion to DocumentReader
        DocumentReader.scenario("Mrz");
        
        // start process of scanning document
        DocumentReader.scanDocument(
            function (message) {
                alert(message);
                str = JSON.stringify(message, null, 4); // (Optional) beautiful indented output.
                console.log(str); // Logs output to dev tools console.
            },
            function (error) {
                alert(error);
            }
        );
    },
    
    ...
};
 
...
  1. Run cordova platform add ios for iOS version
  2. Run cordova platform add android for Android version
  3. Run iOS or Android project.

Package Sidebar

Install

npm i cordova-plugin-documentreader-mrz

Weekly Downloads

5

Version

4.2.1

License

commercial

Unpacked Size

161 MB

Total Files

48

Last publish

Collaborators

  • regula