Skip to content

selfree/nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DBR Node.js Extension

Version 7.0

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

[email protected]

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 7.0\\Components\\C_C++\\Lib\\DBRx64.lib and E:\\Program Files (x86)\\Dynamsoft\\Barcode Reader 7.0\\Components\\C_C++\\Redist\\x64\\ with yours.

Build the Node.js extension:

node-gyp configure
node-gyp build

For Visual Studio 2019 Community

node-gyp configure --msbuild_path="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" --msvs_version=2017
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

About

Build Node.js extension with Dynamsoft Barcode Reader.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 88.2%
  • C++ 8.6%
  • Python 2.0%
  • JavaScript 1.2%