Package Exports
- barcode4nodejs
- barcode4nodejs/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (barcode4nodejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Node.js Barcode Reader SDK
The Node.js barcode reader SDK is implemented by wrapping Dynamsoft Barcode Reader C++ SDK. It helps developers to build Node.js barcode apps for Windows, Linux, macOS, and Raspberry Pi.
What You Should Know
Requirements
Dynamsoft Barcode Reader v8.8
Platform-specific C/C++ compiler
node-gyp
npm i node-gyp -g
Quick Usage
const dbr = require('barcode4nodejs');
dbr.initLicense("LICENSE-KEY")
dbr.decodeFileAsync("YOUR IMAGE FILE", dbr.formats.OneD | dbr.formats.PDF417 | dbr.formats.QRCode | dbr.formats.DataMatrix | dbr.formats.Aztec, function(err, msg){
console.log(msg)
}, "");
How to Customize and Build the Module for Windows, Linux, macOS and Raspberry Pi
Get the source code:
git clone https://github.com/yushulx/nodejs-barcode.git
Edit
src/dbr.cc
andindex.js
.Download Dynamsoft C++ Barcode SDK. Copy header files to
src
folder and copy platform-specific shared libraries toplatforms
folder.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
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.
APIs
- initLicense(license-key)
- decodeFileAsync(fileName, barcodeTypes, callback, template)
- decodeFileStreamAsync(fileStream, fileSize, barcodeTypes, callback, template)
- decodeBase64Async(base64, barcodeTypes, callback, template)
- decodeYUYVAsync(buffer, width, height, barcodeTypes, callback, template)
- decodeBufferAsync(buffer, width, height, stride, barcodeTypes, callback, template, maxBufferLength)
To customize a template, you can visit the barcode reader online demo and go to the advanced settings. Setting template as "" is enough for most cases.
Set barcodeTypes
barcodeTypes = dbr.formats.OneD | dbr.formats.PDF417 | dbr.formats.QRCode | dbr.formats.DataMatrix | dbr.formats.Aztec
Use template
let params = {
"ImageParameter": {
"Name": "Custom_143301_827",
"BarcodeFormatIds": [
"BF_ALL"
],
"DeblurLevel": 9,
"ExpectedBarcodesCount": 100,
"ScaleDownThreshold": 1200000,
"Timeout": 100000
},
"Version": "3.0"
};
template = JSON.stringify(params);