Skip to content

Commit

Permalink
Merge pull request #23 from yushulx/dcv
Browse files Browse the repository at this point in the history
DBR v10.x
  • Loading branch information
yushulx authored Oct 29, 2024
2 parents 2bc868f + 160f4be commit 8d2ff3f
Show file tree
Hide file tree
Showing 74 changed files with 9,086 additions and 4,549 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/examples/RESTful-service/node_modules
node_modules
build
package-lock.json
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Node.js Barcode & QR Code SDK
The Node.js barcode QR code SDK is implemented by wrapping [Dynamsoft Barcode Reader C++ SDK](https://www.dynamsoft.com/barcode-reader/overview/). It helps developers to build Node.js barcode and QR code scanning applications for **Windows**, **Linux**, **macOS**, **Raspberry Pi** and **Jetson Nano**.

## Dynamsoft Barcode Reader SDK Version
**v9.6.40**

## License Key for SDK
[![](https://img.shields.io/badge/Get-30--day%20FREE%20Trial-blue)](https://www.dynamsoft.com/customer/license/trialLicense/?product=dcv&package=cross-platform)
Expand Down Expand Up @@ -60,7 +58,7 @@ The Node.js barcode QR code SDK is implemented by wrapping [Dynamsoft Barcode Re
## API
- `initLicense(license: string): void`
- `createInstance(readerType: readerTypes): BarcodeReader`
- `createInstance(): BarcodeReader`
- `getVersion(): string`
**Asynchronous Methods**
Expand Down
39 changes: 29 additions & 10 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -21,51 +21,70 @@
"cflags_cc": ["-std=c++11", "-DNAPI_CPP_EXCEPTIONS", "-fexceptions"],
"ldflags": ["-Wl,-rpath,'$$ORIGIN'"],
"libraries": [
"-lDynamsoftBarcodeReader", "-L../platforms/linux/<(arch)"
"-lDynamsoftCore", "-lDynamsoftLicense", "-lDynamsoftCaptureVisionRouter", "-lDynamsoftUtility", "-L../platforms/linux/<(arch)"
],
"copies": [
{
"destination": "build/Release/",
"files": [
"./platforms/linux/<(arch)/libDynamicImage.so",
"./platforms/linux/<(arch)/libDynamicPdf.so",
"./platforms/linux/<(arch)/libDynamicPdfCore.so",
"./platforms/linux/<(arch)/libDynamsoftBarcodeReader.so",
"./platforms/linux/<(arch)/libDynamsoftLicenseClient.so",
"./platforms/linux/<(arch)/libDynamicPdf.so"
"./platforms/linux/<(arch)/libDynamsoftCaptureVisionRouter.so",
"./platforms/linux/<(arch)/libDynamsoftCore.so",
"./platforms/linux/<(arch)/libDynamsoftImageProcessing.so",
"./platforms/linux/<(arch)/libDynamsoftLicense.so",
"./platforms/linux/<(arch)/libDynamsoftUtility.so",
]
}
]
}],
["OS=='win'", {
"defines": ["WINDOWS_DBR", "NAPI_CPP_EXCEPTIONS"],
"libraries": [
"-l../platforms/windows/DBRx64.lib"
"-l../platforms/windows/DynamsoftCorex64.lib", "-l../platforms/windows/DynamsoftLicensex64.lib", "-l../platforms/windows/DynamsoftCaptureVisionRouterx64.lib", "-l../platforms/windows/DynamsoftUtilityx64.lib"
],
"copies": [
{
"destination": "build/Release/",
"files": [
"./platforms/windows/DynamicImagex64.dll",
"./platforms/windows/DynamicPdfCorex64.dll",
"./platforms/windows/DynamicPdfx64.dll",
"./platforms/windows/DynamsoftBarcodeReaderx64.dll",
"./platforms/windows/DynamsoftLicenseClientx64.dll",
"./platforms/windows/vcomp110.dll",
"./platforms/windows/DynamicPdfx64.dll"
"./platforms/windows/DynamsoftCaptureVisionRouterx64.dll",
"./platforms/windows/DynamsoftCorex64.dll",
"./platforms/windows/DynamsoftImageProcessingx64.dll",
"./platforms/windows/DynamsoftLicensex64.dll",
"./platforms/windows/DynamsoftUtilityx64.dll",
"./platforms/windows/vcomp140.dll"
]
}
]

}],
["OS=='mac'", {
"defines": ["MAC_DBR"],
"cflags": ["-std=c++11", "-DNAPI_CPP_EXCEPTIONS"],
"cflags_cc": ["-std=c++11", "-DNAPI_CPP_EXCEPTIONS"],
"ldflags": ["-Wl,-rpath,@loader_path"],
"libraries": [
"-lDynamsoftBarcodeReader", "-L../platforms/macos"
"-lDynamsoftCore", "-lDynamsoftLicense", "-lDynamsoftCaptureVisionRouter", "-lDynamsoftUtility", "-L../platforms/macos"
],
"copies": [
{
"destination": "build/Release/",
"files": [
"./platforms/macos/libDynamicImagex64.dylib",
"./platforms/macos/libDynamicPdf.dylib",
"./platforms/macos/libDynamicPdfCore.dylib",
"./platforms/macos/libDynamsoftBarcodeReader.dylib",
"./platforms/macos/libDynamsoftLicenseClient.dylib",
"./platforms/macos/libDynamicPdf.dylib"
"./platforms/macos/libDynamsoftCaptureVisionRouter.dylib",
"./platforms/macos/libDynamsoftCore.dylib",
"./platforms/macos/libDynamsoftImageProcessing.dylib",
"./platforms/macos/libDynamsoftLicense.dylib",
"./platforms/macos/libDynamsoftUtility.dylib",
]
}
]
Expand Down
27 changes: 19 additions & 8 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export enum formats {
ALL = 0xFE3FFFFF,
ALL = 0xFFFFFFFEFFFFFFFF,
ONED = 0x003007FF,
GS1_DATABAR = 0x0003F800,
CODE_39 = 0x1,
Expand All @@ -21,6 +21,7 @@ export enum formats {
GS1_DATABAR_EXPANDED_STACKED = 0x10000,
GS1_DATABAR_LIMITED = 0x20000,
PATCHCODE = 0x00040000,
CODE_32 = 0x1000000,
PDF417 = 0x02000000,
QR_CODE = 0x04000000,
DATAMATRIX = 0x08000000,
Expand All @@ -30,12 +31,22 @@ export enum formats {
MICRO_PDF417 = 0x00080000,
GS1_COMPOSITE = 0x80000000,
MSI_CODE = 0x100000,
CODE_11 = 0x200000
}

export enum readerTypes {
DEFAULT = "",
CONCURRENT = "concurrent",
CODE_11 = 0x200000,
TWO_DIGIT_ADD_ON = 0x400000,
TWO_FIVE_DIGIT_ADD_ON = 0x800000,
MATRIX_25 = 0x1000000000,
POSTALCODE = 0x3F0000000000000,
NONSTANDARD_BARCODE = 0x100000000,
USPSINTELLIGENTMAIL = 0x10000000000000,
POSTNET = 0x20000000000000,
PLANET = 0x40000000000000,
AUSTRALIANPOST = 0x80000000000000,
RM4SCC = 0x100000000000000,
KIX = 0x200000000000000,
DOTCODE = 0x200000000,
PHARMACODE_ONE_TRACK = 0x400000000,
PHARMACODE_TWO_TRACK = 0x800000000,
PHARMACODE = 0xC00000000
}

export type BarcodeResult = {
Expand Down Expand Up @@ -83,7 +94,7 @@ export function getVersion(): string;
export function initLicense(license: string): void;
export function setLicenseCachePath(path: string): void;
export function destroyInstance(): void;
export function createInstance(readerType: readerTypes): BarcodeReader;
export function createInstance(): BarcodeReader;

// Asynchronous API
export function decodeFileAsync(filePath: string, format: formats, callback?: (err: Error | null, result?: BarcodeResult[]) => void, template?: string): void;
Expand Down
38 changes: 23 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const dbr = loadDbr();

var barcodeReader = null;
var formats = {
ALL: 0xFE3FFFFF,
ALL: 0xFFFFFFFEFFFFFFFF,
ONED: 0x003007FF,
GS1_DATABAR: 0x0003F800,
CODE_39: 0x1,
Expand All @@ -25,6 +25,7 @@ var formats = {
GS1_DATABAR_EXPANDED_STACKED: 0x10000,
GS1_DATABAR_LIMITED: 0x20000,
PATCHCODE: 0x00040000,
CODE_32: 0x1000000,
PDF417: 0x02000000,
QR_CODE: 0x04000000,
DATAMATRIX: 0x08000000,
Expand All @@ -34,19 +35,29 @@ var formats = {
MICRO_PDF417: 0x00080000,
GS1_COMPOSITE: 0x80000000,
MSI_CODE: 0x100000,
CODE_11: 0x200000
};

var readerTypes = {
DEFAULT: "",
CONCURRENT: "concurrent"
CODE_11: 0x200000,
TWO_DIGIT_ADD_ON: 0x400000,
TWO_FIVE_DIGIT_ADD_ON: 0x800000,
MATRIX_25: 0x1000000000,
POSTALCODE: 0x3F0000000000000,
NONSTANDARD_BARCODE: 0x100000000,
USPSINTELLIGENTMAIL: 0x10000000000000,
POSTNET: 0x20000000000000,
PLANET: 0x40000000000000,
AUSTRALIANPOST: 0x80000000000000,
RM4SCC: 0x100000000000000,
KIX: 0x200000000000000,
DOTCODE: 0x200000000,
PHARMACODE_ONE_TRACK: 0x400000000,
PHARMACODE_TWO_TRACK: 0x800000000,
PHARMACODE: 0xC00000000
};

var barcodeTypes = formats.ALL;

function checkBarcodeReader() {
if (barcodeReader == null) {
barcodeReader = new dbr.BarcodeReader(readerTypes.DEFAULT);
barcodeReader = new dbr.BarcodeReader();
}
}
module.exports = {
Expand Down Expand Up @@ -178,7 +189,8 @@ module.exports = {
}
const promise = new Promise((resolve, reject) => {
checkBarcodeReader();
barcodeReader.decodeBase64Async(arguments[0], arguments[1], function (err, msg) {
const byteArray = Buffer.from(arguments[0], 'base64')
barcodeReader.decodeFileStreamAsync(byteArray, byteArray.length, arguments[1], function (err, msg) {
setTimeout(() => {
if (err) {
reject(err);
Expand Down Expand Up @@ -345,7 +357,6 @@ module.exports = {
}
},
formats: formats,
readerTypes: readerTypes,
barcodeTypes: barcodeTypes,
getVersion: dbr.getVersionNumber,
initLicense: dbr.initLicense,
Expand All @@ -354,10 +365,7 @@ module.exports = {
barcodeReader.destroyInstance();
barcodeReader = null;
},
createInstance: function (readerType) {
if (readerType === readerTypes.CONCURRENT) {
return new dbr.BarcodeReader(readerTypes.CONCURRENT);
}
return new dbr.BarcodeReader(readerTypes.DEFAULT);
createInstance: function () {
return new dbr.BarcodeReader();
}
};
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "barcode4nodejs",
"version": "9.6.47",
"version": "10.0.0",
"description": "Node.js bindings to Dynamsoft Barcode Reader C/C++ SDK.",
"keywords": [
"barcode",
Expand Down Expand Up @@ -56,5 +56,8 @@
"devDependencies": {
"@types/node": "^20.14.2",
"node-gyp": "^10.1.0"
},
"dependencies": {
"barcode4nodejs": "file:"
}
}
}
Loading

0 comments on commit 8d2ff3f

Please sign in to comment.