# cordova-plugin-dynamsoft-barcode-reader

> Plugin for Dynamsoft Barcode Reader

Latest version **1.7.0** (published 2025-09-22) · Apache 2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install cordova-plugin-dynamsoft-barcode-reader
pnpm add cordova-plugin-dynamsoft-barcode-reader
yarn add cordova-plugin-dynamsoft-barcode-reader
bun add cordova-plugin-dynamsoft-barcode-reader
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.7.0 |
| Published | 2025-09-22 |
| First published | 2021-11-05 |
| Weekly downloads | 0 |
| License | Apache 2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 50.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Xu Lihang |
| Maintainers | xulihang |
| Keywords | ecosystem:cordova, cordova-ios, cordova-android, barcode |

## Links

- npm: https://www.npmjs.com/package/cordova-plugin-dynamsoft-barcode-reader
- Repository: https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader
- Homepage: https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader#readme
- Issues: https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader/issues
- npm.io page: https://npm.io/package/cordova-plugin-dynamsoft-barcode-reader

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.7.0 (latest) — 2025-09-22
- 1.6.1 — 2025-03-26
- 1.6.0 — 2025-03-26
- 1.5.8 — 2022-11-25
- 1.5.7 — 2022-08-30
- 1.5.6 — 2022-08-30
- 1.5.5 — 2022-08-29
- 1.5.4 — 2022-08-29
- 1.5.3 — 2022-08-26
- 1.5.2 — 2022-08-26
- 1.5.1 — 2022-08-19
- 1.5.0 — 2022-08-15
- 1.4.6 — 2022-08-12
- 1.4.5 — 2022-08-12
- 1.4.4 — 2022-06-10
- … 17 more at https://npm.io/package/cordova-plugin-dynamsoft-barcode-reader/versions

## README

# cordova-plugin-dynamsoft-barcode-reader

![version](https://img.shields.io/npm/v/cordova-plugin-dynamsoft-barcode-reader.svg)

[Dynamsoft Barcode Reader](https://www.dynamsoft.com/barcode-reader/overview/) SDK for Cordova.

## SDK Versions Used for Different Platforms

| Product      | Android |    iOS |
| ----------- | ----------- | -----------  |
| Dynamsoft Barcode Reader    | 9.6.40       | 9.6.40     |

## Supported Platforms

* Android
* iOS

## How to use

### Install the plugin

```
$ cordova plugins add cordova-plugin-dynamsoft-barcode-reader
```

Or:

```
$ cordova plugins add https://github.com/xulihang/cordova-plugin-dynamsoft-barcode-reader.git
```

### Methods

* `init`

    Initialize Dynamsoft Barcode Reader with a valid license. You can apply for a trial license [here](https://www.dynamsoft.com/customer/license/trialLicense/?product=dbr).
    
    ```js
    cordova.plugins.DBR.init(license,successCallback,errorCallback);
    ```

* `decode`

    Decode base64 and return results

    ```js
    cordova.plugins.DBR.decode(base64,successCallback,errorCallback);
    ```
    
    A result object has the following properties: `barcodeText`, `barcodeBytesBase64` `barcodeFormat` and localization results: `x1`, `y1`, `x2`, `y2`, `x3`, `y3`, `x4`, `y4`.
    
* `initRuntimeSettingsWithString`
    
    Set runtime settings with JSON template

    ```js
    cordova.plugins.DBR.initRuntimeSettingsWithString(template,onInitSettings);
    ```
    
    A sample template which specifies the barcode format as QR code:
    
    ```json
    {
      "ImageParameter": {
        "BarcodeFormatIds": [
          "BF_QR_CODE"
        ],
        "BinarizationModes": [
          {
            "BlockSizeX": 61,
            "BlockSizeY": 61,
            "LibraryFileName": "",
            "LibraryParameters": "",
            "Mode": "BM_LOCAL_BLOCK"
          }
        ],
        "Description": "",
        "ExpectedBarcodesCount": 1,
        "Name": "Settings",
        "Timeout": 99999
      },
      "Version": "3.0"
    }
    ```
    
* `outputSettingsToString`

    Output the current runtime settings to string.

    ```js
    cordova.plugins.DBR.outputSettingsToString(onOutput);
    ```
    
*  `destroy`

    Destroy the current instance of Dynamsoft Barcode Reader.

    ```js
    cordova.plugins.DBR.destroy(success, error);
    ```

*  `startScanning`

    Open the camera using Dynamsoft Camera Enhancer and decode frames. 

    ```js
    cordova.plugins.DBR.startScanning({"dceLicense":"license","resolution":2}, onScanned, error);
    ```
    
    The scan options:
    
    ```ts
    interface ScanOptions {
      dceLicense?: string;
      rotate?: boolean; //whether to convert the frame to bitmap and rotate it, false by default
      resolution?: number; // check out the following enum of resolution
    }
    
    enum EnumResolution {
      RESOLUTION_AUTO = 0,
      RESOLUTION_480P = 1,
      RESOLUTION_720P = 2,
      RESOLUTION_1080P = 3,
      RESOLUTION_2K = 4,
      RESOLUTION_4K = 5,
    }
    ```

    The `onScanned` callback will return the frame resolution, frame rotation and barcode results.

*  `stopScanning`

    Close the camera.

    ```js
    cordova.plugins.DBR.stopScanning(success, error);
    ```

*  `pauseScanning`

    Pause the camera.

    ```js
    cordova.plugins.DBR.pauseScanning(success, error);
    ```

*  `resumeScanning`

    Resume the camera.

    ```js
    cordova.plugins.DBR.resumeScanning(success, error);
    ```

*  `switchTorch`

    Turn on/off the torch. Value of desiredStatus: `on`, `off`.

    ```js
    cordova.plugins.DBR.switchTorch(desiredStatus, success, error);
    ```

*  `setZoom`

    Set the zoom factor of the camera.

    ```js
    cordova.plugins.DBR.setZoom(zoomFactor, success, error);
    ```
    
*  `setFocus`

    Set the point to focus for the camera.

    ```js
    cordova.plugins.DBR.setFocus(point, success, error);
    ```
    
    Point: `{x:number,y:number}`

*  `getResolution`

    Get the current video resolution in format like this: `1280x720`.

    ```js
    cordova.plugins.DBR.getResolution(success, error);
    ```

## Demo

* [Ionic Angular Barcode Scanner](https://github.com/xulihang/Ionic-Angular-Cordova-Barcode-Scanner)
* [Ionic React Barcode Scanner](https://github.com/xulihang/Ionic-React-Cordova-Barcode-Scanner)

## Ionic Wrapper

[@awesome-cordova-plugins/dynamsoft-barcode-scanner](https://danielsogl.gitbook.io/awesome-cordova-plugins/dynamsoft-barcode-scanner)

## License Versions

For versions >= 1.2.0, License 3 is used.

For versions < 1.2.0, License 1 and 2 are used.

## Supported Barcode Symbologies

* Code 11
* Code 39
* Code 93
* Code 128
* Codabar
* EAN-8
* EAN-13
* UPC-A
* UPC-E
* Interleaved 2 of 5 (ITF)
* Industrial 2 of 5 (Code 2 of 5 Industry, Standard 2 of 5, Code 2 of 5)
* ITF-14 
* QRCode
* DataMatrix
* PDF417
* GS1 DataBar
* Maxicode
* Micro PDF417
* Micro QR
* PatchCode
* GS1 Composite
* Postal Code
* Dot Code
* PharmaCode

## How the plugin is made

1. Use plugman to create a plugin

    ```
    $ plugman create --name DBR --plugin_id cordova-plugin-dynamsoft-barcode-reader --plugin_version 0.0.1
    ```

2. Add platform

    ```
    $ plugman platform add --platform_name ios
    ```
    
    ```
    $ plugman platform add --platform_name android
    ```

3. Implement the plugin

    Modify the `DBR.java`，`DBR.m` and `DBR.js` files. Set up the gradle and cocoapods to use the Android aar file and the iOS framework of Dynamsoft Barcode Reader.

4. Create package.json 

    ```
    $ plugman createpackagejson .
    ```

---
_Source: https://npm.io/package/cordova-plugin-dynamsoft-barcode-reader · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
