Inlite / wabr-nodejs

Web API Barcode Reader - Node.js SDK
MIT License
4 stars 2 forks source link

wabr-nodejs

Web API Barcode Reader Server  (WABR) offers a REST API for the Inlite Research ClearImage Barcode Recognition technology.
This wabr-nodejs SDK simplifies the WABR client-side Node.js development.

Use wabr.ts from this repository in your project; Use sample code from test.ts and sample_code.ts Alternatively use JavaScript versions wabr.js, test.js and sample_code.js

Create a Reader

import modWabr = require('./wabr');

import WABarcodeReader = modWabr.WABarcodeReader;
import WABarcode = modWabr.WABarcode;
import WAUtils = modWabr.WAUtils;
....
var serverUrl: string = "";
var authorization: string = "";
var reader = new WABarcodeReader(serverUrl, authorization);

Where

Read barcodes

Use the ReadAsync() method read barcodes asynchronously. To process both barcodes and exceptions both methods use an instance of a class derived from delReaderCallback class.

ReaderCallback(evnt: string, value, obj) {
    if (evnt == "error") {
        console.log("EXCEPTION: " + value);
    }
    else if (evnt == "barcodes") {
        // Process barcode reading results in value representing WABarcode[]
    }
}
...

var callback: delReaderCallback = this.ReaderCallback;
reader.ReadAsync(image, callback, image, types, directions, tbr_code);

Parameters


Most popular image formats are acceptable as image_source, including *PDF*, *TIF*, *JPEG* etc. Multi-page *PDF* and *TIF* files are supported
To specify several image sources in a single request separate them with the ` | ` character.
  • callback is a required method implementing delReaderCallback interface.

  • obj is a required parameter of any type passed to callback method. If not used set value to null

  • types is an optional string parameter (not case-sensitive) that contains comma-separated barcode types to read. An empty string is the same as 1d,2d. The list of valid type is available in the WABarcodeReader.validtypes variable. Barcodes in this list are:

    1d - same as Code39, Code128, Code93, Ucc128, Codabar, Interleaved2of5, Upca, Upce, Ean8, Ean13
    Code39 - Code 39 Full ASCII
    Code128 - Code 128
    Code93 - Code 93
    Codabar - Codabar
    Ucc128 - GS1-128
    Interleaved2of5 - Inteleaved 2 of 5
    Ean13 - EAN-13
    Ean8 - EAN-8
    Upca - UPC-A
    Upce - UPC-E
    2d - same as Pdf417, DatMatrix, QR
    Pdf417 - PDF417 code
    DataMatrix - DataMatrix code
    QR - QR code
    DrvLic - Driver License, ID Cards and military CAC ID
    postal - same as imb, bpo, aust, sing, postnet
    imb - US Post Intelligent Mail Barcode
    bpo - UK Royal Mail barcode (RM4SCC)
    aust - Australia Post barcode
    sing - Singapore Post barcode
    postnet - Postnet, Planet
    Code39basic - Code 93 Basic
    Patch - Patch code

  • directions is an optional string parameter, which limits the barcode recognition only to barcodes with the specified orientation. This limitation can reduce recognition time. Valid values are:

    an empty string (default) - read barcode in any direction and skew angle.
    horz - read only horizontal barcodes.
    vert - read only vertical barcodes.
    horz, vert - read only horizontal and vertical barcodes.

  • tbr_code is an optional number parameter supplied by Inlite to addresses customer-specific requirements for barcode recognition. Read more about Targeted Barcode Reader (TBR). The default value is 0, meaning TBR is disabled.

  • Use barcode reading results

    The following examples demonstrate processing of an Array of WABarcode. This array is a value parameter of delReaderCallback() method in an instance of a class specified as callback parameter of ReadAsync() and ReadOptAsync() methods.

    Print each barcode text value, type and file name:

    for (var i = 0; i < barcodes.length; i++) {
        var barcode = barcodes[i];
        console.log("Barcode Type:" + barcode.Type + "  File:" + barcode.File);
        }
    

    WABR Decode Values of a Driver License, ID Card or Military CAC Card. To obtain these values include DrvLic in the types parameter of the ReadAsync() call.

    for (var key in barcode.Values)
        console.log(key + " : " + barcode.Values[key]);

    WABarcode properties

    Text - barcode text value (ASCII or UTF-8 if enabled) [string]
    Data - binary data encoded in Pdf417, DataMatrix or QR barcodes [byte array]
    Type - barcode type [string]
    Page - page in multi-page PDF and TIF file [number]
    Top - top coordinate in pixels [number]
    Left - left coordinate in pixels [number]
    Right - right coordinate in pixels [number]
    Bottom - bottom coordinate in pixels [number]
    File - file name of image file. Depending on image_source type it is
                a URL value, base-name of Path, filename of Base64-encoded string (if present) [string]
    Rotation - rotation of barcode on a page. Values: none, upsideDown, left, right or diagonal [string]
    Meta - JSON-formated string representing barcode meta-data [string]
    Values - Driver License fields, such as last name, date of birth etc. [associative array { [key: string]: string } ]