npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

barcode4nodejs

v10.0.4

Published

Node.js bindings to Dynamsoft Barcode Reader C/C++ SDK.

Downloads

1,682

Readme

Node.js Barcode & QR Code SDK

The Node.js barcode QR code SDK is implemented by wrapping Dynamsoft Barcode Reader C++ SDK. It helps developers to build Node.js barcode and QR code scanning applications for Windows, Linux, macOS, Raspberry Pi and Jetson Nano.

License Key for SDK

Pre-requisites

  • Platform-specific C/C++ compiler

  • node-gyp

    npm i node-gyp -g
    npm i node-addon-api -g

Supported Platforms

  • Windows
  • Linux
  • macOS

Supported Barcode Symbologies

  • Linear Barcodes (1D)

    • Code 39 (including Code 39 Extended)
    • Code 93
    • Code 128
    • Codabar
    • Interleaved 2 of 5
    • EAN-8
    • EAN-13
    • UPC-A
    • UPC-E
    • Industrial 2 of 5
  • 2D Barcodes

    • QR Code (including Micro QR Code and Model 1)
    • Data Matrix
    • PDF417 (including Micro PDF417)
    • Aztec Code
    • MaxiCode (mode 2-5)
    • DotCode
  • Patch Code

  • GS1 Composite Code

  • GS1 DataBar

    • Omnidirectional,
    • Truncated, Stacked, Stacked
    • Omnidirectional, Limited,
    • Expanded, Expanded Stacked
  • Postal Codes

    • USPS Intelligent Mail
    • Postnet
    • Planet
    • Australian Post
    • UK Royal Mail

API

  • initLicense(license: string): void
  • createInstance(): BarcodeReader
  • getVersion(): string

Asynchronous Methods

  • decodeFileAsync(filePath: string, format: formats, callback?: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void
  • decodeFileAsync(filePath: string, format: formats, template?: string): Promise<BarcodeResult[]>
  • decodeFileStreamAsync(stream: any, length: number, format: formats, callback?: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void
  • decodeFileStreamAsync(stream: any, length: number, format: formats, template?: string): Promise<BarcodeResult[]>
  • decodeBase64Async(base64String: string, format: formats, callback: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void
  • decodeBase64Async(base64String: string, format: formats, template?: string): Promise<BarcodeResult[]>
  • decodeYUYVAsync(data: any, width: number, height: number, format: formats, callback?: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void
  • decodeYUYVAsync(data: any, width: number, height: number, format: formats, template?: string): Promise<BarcodeResult[]>
  • decodeBufferAsync(buffer: any, width: number, height: number, stride: number, format: formats, callback?: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void
  • decodeBufferAsync(buffer: any, width: number, height: number, stride: number, format: formats, template?: string): Promise<BarcodeResult[]>

Synchronous Methods

  • decodeFile(filePath: string, format: formats, template?: string): BarcodeResult[]
  • decodeFileStream(stream: any, length: number, format: formats, template?: string): BarcodeResult[]
  • decodeBase64(base64String: string, format: formats, template?: string): BarcodeResult[]
  • decodeYUYV(data: any, width: number, height: number, format: formats, template?: string): BarcodeResult[]
  • decodeBuffer(buffer: any, width: number, height: number, stride: number, format: formats, template?: string): BarcodeResult[]

Template Usage

  1. Visit the barcode reader online demo.
  2. Customize parameters in advanced settings and then download the template.

For example:

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);

Quick Usage

Replace LICENSE-KEY with your own license key.

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);
  for (index in msg) {
    result = msg[index];
    console.log('Format: ' + result['format']);
    console.log('Value : ' + result['value']);
    console.log('x1: ' + result['x1']);
    console.log('y1 : ' + result['y1']);
    console.log('x2: ' + result['x2']);
    console.log('y2 : ' + result['y2']);
    console.log('x3: ' + result['x3']);
    console.log('y3: ' + result['y3']);
    console.log('x4: ' + result['x4']);
    console.log('y4: ' + result['y4']);
    console.log('page: ' + result['page']);
    console.log('decoding time: ' + result['time']);
  }
}, "");

// Or
(async function () {
  try {
    var result = await dbr.decodeFileAsync("YOUR IMAGE FILE", dbr.formats.OneD | dbr.formats.PDF417 | dbr.formats.QRCode | dbr.formats.DataMatrix | dbr.formats.Aztec, "");
    console.log(result);
  } catch (error) {
    console.log(error);
  }
})();

How to Customize and Build the Module

  1. Get the source code:

    git clone https://github.com/yushulx/nodejs-barcode.git
  2. Download Dynamsoft C++ Barcode SDK. Copy header files to src folder and copy platform-specific shared libraries to platforms folder.

  3. Edit src/dbr.cc and index.js.

  4. Build the Node.js extension:

    node-gyp configure
    node-gyp build
    
    # For macOS
    install_name_tool -change @rpath/libDynamsoftCore.dylib @loader_path/libDynamsoftCore.dylib build/Release/dbr.node
    install_name_tool -change @rpath/libDynamsoftLicense.dylib @loader_path/libDynamsoftLicense.dylib build/Release/dbr.node
    install_name_tool -change @rpath/libDynamsoftCaptureVisionRouter.dylib @loader_path/libDynamsoftCaptureVisionRouter.dylib build/Release/dbr.node
    install_name_tool -change @rpath/libDynamsoftUtility.dylib @loader_path/libDynamsoftUtility.dylib build/Release/dbr.node
    install_name_tool -change @rpath/libDynamsoftImageProcessing.dylib @loader_path/libDynamsoftImageProcessing.dylib build/Release/libDynamsoftUtility.dylib

    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

  • Command Line

    node test.js -f MultiPage.pdf

    image

  • Web

    npm install
    node server.js

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

  • 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
  • Linux Camera

    npm install v4l2camera
    node camera_barcode_reader.js
  • RESTful Service

    npm install restify
    node server.js

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

  • OpenCV

  • Node-RED

    Node RED barcode