Build Node.js extension with Dynamsoft Barcode Reader.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples
images Support DBR 6.3 Aug 20, 2018
src
.gitignore
LICENSE
README.md Support template Nov 8, 2018

README.md

DBR Node.js Extension

Version 6.4

The repository aims to help developers build Node.js barcode apps with Dynamsoft Barcode Reader in Windows, Linux, macOS, and Raspberry Pi.

License

Get the trial license.

Contact Us

support@dynamsoft.com

Environment

Node v8.11.3

Installation

How to Build

Windows

Change directory to src.

cd src

Edit binding.gyp. Replace E:\\Program Files (x86)\\Dynamsoft\\Barcode Reader 6.4\\Components\\C_C++\\Lib\\DBRx64.lib and E:\\Program Files (x86)\\Dynamsoft\\Barcode Reader 6.4\\Components\\C_C++\\Redist\\x64\\ with yours.

Build the Node.js extension:

node-gyp configure
node-gyp build

Linux, macOS and Raspberry Pi

Change directory to src.

cd src

Edit binding.gyp. Replace /mnt/g/nodejs/libDynamsoftBarcodeReader.so or /mnt/g/nodejs/libDynamsoftBarcodeReader.dylib with yours.

Build the Node.js extension:

node-gyp configure
node-gyp build

Examples

  • examples/command-line

    node test.js -f test.tif
    
  • examples/web

    npm install
    node server.js
    

    Open http://localhost:2018/index.htm in web browsers.

  • examples/desktop-electron

    cd src
    node-gyp rebuild --target=0.36.7 --arch=x64 --dist-url=https://atom.io/download/atom-shell
    
    cd examples/desktop-electron
    npm install
    npm start
    
  • examples/linux-camera

    npm install v4l2camera
    node camera_barcode_reader.js
    
  • examples/RESTful-service

    npm install restify
    node server.js
    

    Open https://< ip >:2018 to scan barcodes in web browsers.

Template Settings

https://www.dynamsoft.com/help/Barcode-Reader/devguide/Template/TemplateSettingsList.html

How to Set Barcode Types

The simplest way to set barcode types:

var barcodeTypes = dbr.formats.OneD;
decodeFileAsync(fileName, barcodeTypes, callback);

Alternatively, you can use template:

// From file
template = fs.readFileSync("<template file>");

// From JSON object
let params = {
    "Version": "2.0",
    "ImageParameter": {
      "Name": "Custom_143301_827",
      "BarcodeFormatIds": [
        "PDF417"
      ],
      "ExpectedBarcodesCount": 9,
      "ScaleDownThreshold": 1200000,
      "BinarizationBlockSize": 5
    }
  };
template = JSON.stringify(params);

decodeFileAsync(fileName, 0, callback, template);

Related Articles