angular scan id card into json

1.9k Views Asked by At

I have a new requirement in my AngularJS application. When a new client (patient, in my case) is coming to the medical center for the first time, I must have the possibility to scan his/her ID card, and in this way the admission process can be speeded up, because every data included in the ID card can be automatically read into their corresponding form fields. How can I do this from a computer (not from a mobile device)?

The idea is having this possibility, so the form is automatically completed into my Angular JS form. I suppose every read field should be loaded into a JSON structure (one JSON structure for the whole form). If all data is correct, it is sent to my Node JS backend as usual.

Is it possible to do this in any way? Thank you very much.

2

There are 2 best solutions below

1
On

From your comments I'm am assuming that you have a scanner attached to a Windows desktop computer. Typically, those types of scanners have a TWAIN driver to control the scanner from the computer. TWAIN is a message based system and requires a Windows handle. That being said, there is no direct way to access TWAIN devices from within a browser application. However, you can create a service proxy to get around this.

There is a white paper that describes how to develop this type of proxy using LEADTOOLS, a 3rd party SDK: LEADTOOLS HTML5 Scanning White Paper

LEADTOOLS can help you find and extract text, numeric, and date information from any driver's license or identification card, including field like:

  • Name
  • ID Number
  • Address
  • Gender
  • Race
  • Organ donor election
  • Signature
  • Date of Birth
  • Issuing Date
  • Expiration Date

I would probably process and extract in the scanning proxy on the desktop since you already have the image and you will probably want to return the extracted data as JSON anyway. For more information, check out the LEADTOOLS Driver's License Recognition and Processing SDK page.

If you want to try these things out, you can for free. Technical support is also free and can help guide you through this part of your project.

Disclaimer: I work for LEAD Technologies.

2
On

Assuming you are using USB scanner you could try something like:

 var chars = []
 $document.on('keydown', function (e) {
        if (e.which === 13) {          
            //broadcast event 
            var scannerValue = chars.join("");            
            console.log('broadcast cpScannerEvent: ' + scannerValue );
            $rootScope.$broadcast('cpScannerEvent', { scanner: scannerValue });
            //clean buffer 
            chars = [];
        } else {
            chars.push(String.fromCharCode(e.which));
        }

    });