Skip to content

Commit 17b1f28

Browse files
8.8.7
1 parent a86b95c commit 17b1f28

File tree

74 files changed

+1078
-1182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1078
-1182
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ yarn.lock
4040
/*.txt
4141
/.gitattributes
4242
/.*ignore
43-
/DBR-*
43+
/dbr-*
4444
/sampleFromGithub
4545
/src
4646
/Web.config

README.NODE.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Both 1D and 2D barcode symbiology are supported including the popular `Code 39`,
66

77
The library is based on `webassembly` which has been an official feature of Node.js since `LTS 8`. If you are using Node.js LTS 8 and have no plan to upgrade it, check out [how to use the library in Node.js LTS 8](#how-to-use-the-library-in-nodejs-lts-8). That said, Node.js version >= LTS 12 is recommended because the library will try to use `worker_threads` when decoding.
88

9-
> Also see [Dynamsoft JavaScript Barcode SDK for Web](https://github.com/Dynamsoft/javascript-barcode/blob/master/README.md).
9+
Node.js 15+ is required to use online license.
1010

1111
## Get Started
1212

@@ -89,7 +89,7 @@ DBR.BarcodeReader.productKeys = 'PRODUCT-KEYS';
8989
**Full code**
9090

9191
```js
92-
let DBR = require('dynamsoft-node-barcode');
92+
let DBR = require('dynamsoft-javascript-barcode');
9393
// Please visit https://www.dynamsoft.com/customer/license/trialLicense?product=dbr&package=js&utm_source=github to get a trial license
9494
DBR.BarcodeReader.productKeys = 'PRODUCT-KEYS';
9595

@@ -116,13 +116,13 @@ let pReader = null;
116116
To set up the library for decoding, use the APIs `getRuntimeSettings` & `updateRuntimeSettings`.
117117

118118
```js
119-
await barcodeScanner.updateRuntimeSettings("speed");
119+
await reader.updateRuntimeSettings("speed");
120120
```
121121
```js
122-
await barcodeScanner.updateRuntimeSettings("balance");
122+
await reader.updateRuntimeSettings("balance");
123123
```
124124
```js
125-
await barcodeScanner.updateRuntimeSettings("coverage");
125+
await reader.updateRuntimeSettings("coverage");
126126
```
127127
```js
128128
let settings = await reader.getRuntimeSettings();

README.md

Lines changed: 34 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<!--The original doc is hosted here => https://github.com/dynamsoft-docs/barcode-reader-docs-js/blob/preview/programming/javascript/user-guide/index.md -->
2+
13
# Dynamsoft Barcode Reader for Your Website
24

35
Turn your web page into a barcode scanner with just a few lines of code.
@@ -15,7 +17,7 @@ In this guide, you will learn step by step on how to integrate this library into
1517

1618
[TEST THE LIBRARY](https://www.dynamsoft.com/barcode-reader/downloads/?utm_source=github&product=dbr&package=js)
1719

18-
> For back-end barcode reading with Node.js, see [Dynamsoft Barcode Reader for Node](https://github.com/Dynamsoft/javascript-barcode/blob/main/README.NODE.md).
20+
> For back-end barcode reading with Node.js, see [Dynamsoft Barcode Reader for Node](https://www.npmjs.com/package/dynamsoft-node-barcode).
1921
2022
**Table of Contents**
2123

@@ -33,11 +35,11 @@ In this guide, you will learn step by step on how to integrate this library into
3335

3436
**Popular Examples**
3537

36-
* [Basic Implementation](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-mincode.html?ver=latest&utm_source=github)
37-
* [Use the library in Angular](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-angular.html?ver=latest&utm_source=github)
38-
* [Use the library in React](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-reactjs.html?ver=latest&utm_source=github)
39-
* [Use the library in Vue](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-vuejs.html?ver=latest&utm_source=github)
40-
* [Use the library in a PWA APP](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-pwa.html?ver=latest&utm_source=github)
38+
* [Basic Implementation](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-mincode.html?ver=8.8.7&utm_source=github)
39+
* [Use the library in Angular](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-angular.html?ver=8.8.7&utm_source=github)
40+
* [Use the library in React](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-reactjs.html?ver=8.8.7&utm_source=github)
41+
* [Use the library in Vue](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-vuejs.html?ver=8.8.7&utm_source=github)
42+
* [Use the library in a PWA APP](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/helloworld-pwa.html?ver=8.8.7&utm_source=github)
4143

4244
You can also:
4345

@@ -49,9 +51,9 @@ You can also:
4951
Let's start by testing the "Hello World" example of the library which demonstrates how to use the minimum code to enable a web page to read barcodes from a live video stream.
5052

5153
* Basic Requirements
52-
+ Internet connection
54+
+ Internet connection
5355
+ [A supported browser](#system-requirements)
54-
+ Camera access
56+
+ Camera access
5557

5658
### Step One: Check the code of the example
5759

@@ -62,7 +64,7 @@ The complete code of the "Hello World" example is shown below
6264
<html>
6365

6466
<body>
65-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js"></script>
67+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js"></script>
6668
<script>
6769
// initializes and uses the library
6870
(async () => {
@@ -128,13 +130,13 @@ The simplest way to include the library is to use either the [jsDelivr](https://
128130
* jsDelivr
129131

130132
``` html
131-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js"></script>
133+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js"></script>
132134
```
133135

134136
* UNPKG
135137

136138
``` html
137-
<script src="https://unpkg.com/[email protected].3/dist/dbr.js"></script>
139+
<script src="https://unpkg.com/[email protected].7/dist/dbr.js"></script>
138140
```
139141

140142
#### Host the library yourself
@@ -162,7 +164,7 @@ The following shows a few ways to download the library.
162164
Depending on how you downloaded the library and where you put it. You can typically include it like this:
163165

164166
``` html
165-
<script src="/dbr-js-8.8.3/dist/dbr.js"></script>
167+
<script src="/dbr-js-8.8.7/dist/dbr.js"></script>
166168
```
167169

168170
or
@@ -204,7 +206,7 @@ Dynamsoft.DBR.BarcodeReader.productKeys = "t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoL
204206
Or
205207

206208
```html
207-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js" data-productKeys="t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoLrnqjLiQQRSH5DBV1UtIs4..."></script>
209+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js" data-productKeys="t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoLrnqjLiQQRSH5DBV1UtIs4..."></script>
208210
```
209211

210212
#### Specify the location of the "engine" files
@@ -214,7 +216,7 @@ The "engine" files refer to *.worker.js, *.wasm.js and *.wasm, etc. which are lo
214216
The following code uses the jsDelivr CDN, feel free to change it to your own location of these files.
215217

216218
``` javascript
217-
Dynamsoft.DBR.BarcodeScanner.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].3/dist/";
219+
Dynamsoft.DBR.BarcodeScanner.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].7/dist/";
218220
```
219221

220222
### Interact with the library
@@ -307,7 +309,7 @@ As you can see from the above code snippets, there are three types of configurat
307309

308310
Try in [JSFiddle](https://jsfiddle.net/DynamsoftTeam/f24h8c1m/).
309311

310-
See also [settings samples](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/parameter-settings.html?ver=latest&utm_source=github).
312+
See also [settings samples](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/parameter-settings.html?ver=8.8.7&utm_source=github).
311313

312314
#### Customize the UI
313315

@@ -390,7 +392,7 @@ The built-in UI of the `BarcodeScanner` object is defined in the file `dist/dbr.
390392

391393
> Generally, you need to provide a resolution that the camera supports. However, in case a camera does not support the specified resolution, it usually uses the nearest supported resolution. As a result, the selected resolution may not be the actual resolution used. In this case, add an option with the class name `dbrScanner-opt-gotResolution` (as shown above) and the library will then use it to show the actual resolution.
392394

393-
See also [UI customization samples](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/ui-customization.html?ver=latest&utm_source=github).
395+
See also [UI customization samples](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/ui-customization.html?ver=8.8.7&utm_source=github).
394396

395397
Interested to test it further? Read on to learn how to request a 30-day free trial.
396398

@@ -405,28 +407,26 @@ Since v8.2.5, a 7-day free license is used by default if no license specified. N
405407

406408
This library requires the following features which are supported by all modern mainstream browsers:
407409

408-
* `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`
410+
* `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`, `import`
409411

410412
The above four features are required for the library to work.
411413

412414
* `MediaDevices`/`getUserMedia`
413415

414-
This API is only required for in-browser video streaming. If a browser does not support this API, the [Single Frame Mode](https://www.dynamsoft.com/barcode-reader/programming/javascript/api-reference/BarcodeScanner.html?ver=latest&utm_source=github#singleframemode) will be used automatically. If the API exists but doesn't work correctly, the Single Frame Mode can be used as an alternative way to access the camera.
416+
This API is only required for in-browser video streaming. If a browser does not support this API, the [Single Frame Mode](https://www.dynamsoft.com/barcode-reader/programming/javascript/api-reference/BarcodeScanner.html?ver=8.8.7&utm_source=github#singleframemode) will be used automatically. If the API exists but doesn't work correctly, the Single Frame Mode can be used as an alternative way to access the camera.
415417

416418
The following table is a list of supported browsers based on the above requirements:
417419

418420
Browser Name | Version
419421
:-: | :-:
420-
Chrome | v57+ (v59+ on Android/iOS<sup>1</sup>)
421-
Firefox | v52+ (v55+ on Android/iOS<sup>1</sup>)
422-
Edge<sup>2</sup> | v16+
423-
Safari<sup>3</sup> | v11+
422+
Chrome<sup>1</sup> | v63+
423+
Firefox<sup>1</sup> | v67+
424+
Edge | v79+
425+
Safari<sup>2</sup> | v11.1+
424426

425427
<sup>1</sup> iOS 14.3+ is required for camera video streaming in Chrome and Firefox or Apps using webviews.
426428

427-
<sup>2</sup> On legacy Edge (v16 ~ v78), due to strict Same-origin policy, you must host the library files on the same domain as your web page.
428-
429-
<sup>3</sup> Safari 11.2.2 ~ 11.2.6 are not supported.
429+
<sup>2</sup> Safari 11.2.2 ~ 11.2.6 are not supported.
430430

431431
Apart from the browsers, the operating systems may impose some limitations of their own that could restrict the use of the library. Browser compatibility ultimately depends on whether the browser on that particular operating system supports the features listed above.
432432

@@ -475,101 +475,11 @@ Optionally, you may also need to [specify the location of the "engine" files](#s
475475

476476
## Advanced Usage
477477

478-
### Read a specific area/region
479-
480-
To speed up the scanning process, you can choose to scan only a specific area/region.
481-
482-
```javascript
483-
let settings = await scanner.getRuntimeSettings();
484-
/*
485-
* The following code shrinks the decoding region by 25% on all sides
486-
*/
487-
settings.region.regionMeasuredByPercentage = 1;
488-
settings.region.regionLeft = 25;
489-
settings.region.regionTop = 25;
490-
settings.region.regionRight = 75;
491-
settings.region.regionBottom = 75;
492-
await scanner.updateRuntimeSettings(settings);
493-
```
494-
495-
[Try in JSFiddle](https://jsfiddle.net/DynamsoftTeam/taykq592/)
496-
497-
### Show internal logs
498-
499-
Include the following in your code to print internal logs in the console.
500-
501-
```javascript
502-
Dynamsoft.DBR.BarcodeReader._onLog = console.log;
503-
```
504-
505-
### Set mode arguments
506-
507-
To precisely control a mode, you can adjust its specific parameters.
508-
509-
```javascript
510-
let settings = await scanner.getRuntimeSettings();
511-
512-
/*
513-
* The following code sets the sensitivity of the TextureDetectionModes to 9
514-
*/
515-
516-
settings.furtherModes.textureDetectionModes = [
517-
Dynamsoft.DBR.EnumTextureDetectionMode.TDM_GENERAL_WIDTH_CONCENTRATION, 0, 0, 0, 0, 0, 0, 0
518-
];
519-
520-
await scanner.updateRuntimeSettings(settings);
521-
// The 2nd parameter 0 specifies the first mode of TextureDetectionModes, which is "Dynamsoft.DBR.EnumTextureDetectionMode.TDM_GENERAL_WIDTH_CONCENTRATION" in this case.
522-
await scanner.setModeArgument("TextureDetectionModes", 0, "Sensitivity", "9");
523-
```
524-
525-
### Display the intermediate result images or the original canvas
526-
527-
The intermediate result images are created when `intermediateResultTypes` is set in `RuntimeSettings` . Then they can be returned with the method `getIntermediateCanvas()` . These images can be used to show and debug the barcode reading process.
528-
529-
The method `getOriginalImageInACanvas()` returns a canvas which holds the image to be passed to the barcode reader engine for decoding.
530-
531-
> *NOTE*
532-
>
533-
> For efficiency, the library may utilize WebGL (Web Graphics Library) for preprocessing an image before passing it to the barcode reader engine. If WebGL is used, the image captured from the camera will not be rendered on the canvas, instead, it gets processed by WebGL first and then is passed to the barcode reader engine directly. In this case, there won't be an original canvas. Therefore, if `ifSaveOriginalImageInACanvas` is set to `true` for a `BarcodeReader` or `BarcodeScanenr` instance, the WebGL feature will be disabled for that instance.
534-
>
535-
> On the other hand, if WebGL is disabled and you try to get the intermediate result specified by `EnumIntermediateResultType.IRT_ORIGINAL_IMAGE` , it will be exactly the same image as you would get with `getOriginalImageInACanvas()` .
536-
537-
The following shows how to display these images on the page
538-
539-
```html
540-
<div id='scannerV' style="width:50vw;height:50vh"></div>
541-
<div id='cvses'></div>
542-
```
543-
544-
```javascript
545-
(async () => {
546-
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
547-
/* The default of `_bUseWebgl` is true which means the intermediate result for
548-
IRT_ORIGINAL_IMAGE will be one that has been preprocessed by WebGL */
549-
scanner._bUseWebgl = false;
550-
document.getElementById('scannerV').appendChild(scanner.getUIElement());;
551-
await scanner.updateRuntimeSettings('balance');
552-
let rs = await scanner.getRuntimeSettings();
553-
rs.intermediateResultTypes = 1;
554-
await scanner.updateRuntimeSettings(rs);
555-
scanner.onUnduplicatedRead = async (txt, result) => {
556-
try {
557-
let cvss = await scanner.getIntermediateCanvas();
558-
for (let cvs of cvss) {
559-
document.getElementById('cvses').appendChild(cvs);
560-
}
561-
scanner.destroy();
562-
} catch (ex) {
563-
console.error(ex);
564-
}
565-
};
566-
await scanner.show();
567-
})();
568-
```
478+
In addition to the content mentioned above, the library has many other settings and options that you can adjust to best suit your usage. To read more, please see [advanced usage](https://www.dynamsoft.com/barcode-reader/programming/javascript/user-guide/advanced-usage.html?ver=8.8.7&utm_source=github).
569479

570480
## How to Upgrade
571481

572-
If you are using an older version of the library and want to upgrade it to the latest version, please read more on [how to upgrade](https://www.dynamsoft.com/barcode-reader/programming/javascript/upgrade-guide/?ver=latest&utm_source=github).
482+
If you are using an older version of the library and want to upgrade it to the latest version, please read more on [how to upgrade](https://www.dynamsoft.com/barcode-reader/programming/javascript/upgrade-guide/?ver=8.8.7&utm_source=github).
573483

574484
## FAQ
575485

@@ -597,3 +507,10 @@ To make sure your web application can access the camera, please configure your w
597507
- IIS: [Create a Self Signed Certificate in IIS](https://aboutssl.org/how-to-create-a-self-signed-certificate-in-iis/)
598508
- Tomcat: [Setting Up SSL on Tomcat in 5 minutes](https://dzone.com/articles/setting-ssl-tomcat-5-minutes)
599509
- Node.js: [npm tls](https://nodejs.org/docs/v0.4.1/api/tls.html)
510+
511+
### Accounting for newline characters in the barcode result
512+
When it comes to HTML, newline characters (`\n`) are not interpreted as they normally would. Therefore, if a barcode result contains a newline character, and you display the result in an alert box or some other text element, then the newline character will most probably be ignored.
513+
514+
There are two ways in which you can resolve this:
515+
1. Wrap the element used to display the result in a `<pre>` element.
516+
2. Manually replace each `\n` character in the result with `<br \>`

dist/class/barcodereader.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class BarcodeReader {
3535
* ```
3636
* For convenience, you can set `license` in `script` tag instead.
3737
* ```html
38-
* <script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js" data-license="PRODUCT-KEYS"></script>
38+
* <script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js" data-license="PRODUCT-KEYS"></script>
3939
* ```
4040
*/
4141
static set license(keys: string);
@@ -87,7 +87,7 @@ export default class BarcodeReader {
8787
* If the auto-explored engine location is incorrect, you can manually specify the engine location.
8888
* The property needs to be set before [[loadWasm]].
8989
* ```js
90-
* Dynamsoft.DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].3/dist/";
90+
* Dynamsoft.DBR.BarcodeReader.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].7/dist/";
9191
* await Dynamsoft.DBR.BarcodeReader.loadWasm();
9292
* ```
9393
*/

dist/class/barcodescanner.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class BarcodeScanner extends BarcodeReader {
2424
* The url of the default scanner UI.
2525
* Can only be changed before `createInstance`.
2626
* ```js
27-
* Dynamsoft.DBR.BarcodeScanner.defaultUIElementURL = "https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.scanner.html";
27+
* Dynamsoft.DBR.BarcodeScanner.defaultUIElementURL = "https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.scanner.html";
2828
* let pScanner = null;
2929
* (async()=>{
3030
* let scanner = await (pScanner = pScanner || Dynamsoft.DBR.BarcodeScanner.createInstance());
@@ -371,7 +371,7 @@ export default class BarcodeScanner extends BarcodeReader {
371371
* Get current camera resolution.
372372
* ```js
373373
* let rsl = await scanner.getResolution();
374-
* console.log(rsl.width + " x " + rsl.height);
374+
* console.log(rsl[0] + " x " + rsl[1]);
375375
* ```
376376
* @category Camera Settings
377377
*/
@@ -655,7 +655,7 @@ export default class BarcodeScanner extends BarcodeReader {
655655
/**
656656
* Bind UI, open the camera, start decoding, and remove the UIElement `display` style if the original style is `display:none;`.
657657
* ```js
658-
* await scanner.setUIElement("https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.scanner.html");
658+
* await scanner.setUIElement("https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.scanner.html");
659659
* scanner.onUniqueRead = (txt, result) => { alert(txt); console.log(result); };
660660
* await scanner.show();
661661
* // await scanner.hide();

dist/dbr-8.8.3.full.wasm

-3.81 MB
Binary file not shown.

0 commit comments

Comments
 (0)