Skip to content

Commit 13d50bb

Browse files
authored
Merge pull request #107 from Dynamsoft/_dev
8.8.7
2 parents 4ac8dc3 + 17b1f28 commit 13d50bb

File tree

74 files changed

+1076
-1180
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

+1076
-1180
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

@@ -54,9 +56,9 @@ Other resources:
5456
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.
5557

5658
* Basic Requirements
57-
+ Internet connection
59+
+ Internet connection
5860
+ [A supported browser](#system-requirements)
59-
+ Camera access
61+
+ Camera access
6062

6163
### Step One: Check the code of the example
6264

@@ -67,7 +69,7 @@ The complete code of the "Hello World" example is shown below
6769
<html>
6870

6971
<body>
70-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js"></script>
72+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js"></script>
7173
<script>
7274
// initializes and uses the library
7375
(async () => {
@@ -133,13 +135,13 @@ The simplest way to include the library is to use either the [jsDelivr](https://
133135
* jsDelivr
134136

135137
``` html
136-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js"></script>
138+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js"></script>
137139
```
138140

139141
* UNPKG
140142

141143
``` html
142-
<script src="https://unpkg.com/[email protected].3/dist/dbr.js"></script>
144+
<script src="https://unpkg.com/[email protected].7/dist/dbr.js"></script>
143145
```
144146

145147
#### Host the library yourself
@@ -167,7 +169,7 @@ The following shows a few ways to download the library.
167169
Depending on how you downloaded the library and where you put it. You can typically include it like this:
168170

169171
``` html
170-
<script src="/dbr-js-8.8.3/dist/dbr.js"></script>
172+
<script src="/dbr-js-8.8.7/dist/dbr.js"></script>
171173
```
172174

173175
or
@@ -209,7 +211,7 @@ Dynamsoft.DBR.BarcodeReader.productKeys = "t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoL
209211
Or
210212

211213
```html
212-
<script src="https://cdn.jsdelivr.net/npm/[email protected].3/dist/dbr.js" data-productKeys="t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoLrnqjLiQQRSH5DBV1UtIs4..."></script>
214+
<script src="https://cdn.jsdelivr.net/npm/[email protected].7/dist/dbr.js" data-productKeys="t0068NQAAACgTVU2aucyxqETXKkiomqhV7YoLrnqjLiQQRSH5DBV1UtIs4..."></script>
213215
```
214216

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

221223
``` javascript
222-
Dynamsoft.DBR.BarcodeScanner.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].3/dist/";
224+
Dynamsoft.DBR.BarcodeScanner.engineResourcePath = "https://cdn.jsdelivr.net/npm/[email protected].7/dist/";
223225
```
224226

225227
### Interact with the library
@@ -312,7 +314,7 @@ As you can see from the above code snippets, there are three types of configurat
312314

313315
Try in [JSFiddle](https://jsfiddle.net/DynamsoftTeam/f24h8c1m/).
314316

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

317319
#### Customize the UI
318320

@@ -395,7 +397,7 @@ The built-in UI of the `BarcodeScanner` object is defined in the file `dist/dbr.
395397

396398
> 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.
397399

398-
See also [UI customization samples](https://www.dynamsoft.com/barcode-reader/programming/javascript/samples-demos/ui-customization.html?ver=latest&utm_source=github).
400+
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).
399401

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

@@ -410,28 +412,26 @@ Since v8.2.5, a 7-day free license is used by default if no license specified. N
410412

411413
This library requires the following features which are supported by all modern mainstream browsers:
412414

413-
* `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`
415+
* `WebAssembly`, `Blob`, `URL`/`createObjectURL`, `Web Workers`, `import`
414416

415417
The above four features are required for the library to work.
416418

417419
* `MediaDevices`/`getUserMedia`
418420

419-
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.
421+
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.
420422

421423
The following table is a list of supported browsers based on the above requirements:
422424

423425
Browser Name | Version
424426
:-: | :-:
425-
Chrome | v57+ (v59+ on Android/iOS<sup>1</sup>)
426-
Firefox | v52+ (v55+ on Android/iOS<sup>1</sup>)
427-
Edge<sup>2</sup> | v16+
428-
Safari<sup>3</sup> | v11+
427+
Chrome<sup>1</sup> | v63+
428+
Firefox<sup>1</sup> | v67+
429+
Edge | v79+
430+
Safari<sup>2</sup> | v11.1+
429431

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

432-
<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.
433-
434-
<sup>3</sup> Safari 11.2.2 ~ 11.2.6 are not supported.
434+
<sup>2</sup> Safari 11.2.2 ~ 11.2.6 are not supported.
435435

436436
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.
437437

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

481481
## Advanced Usage
482482

483-
### Read a specific area/region
484-
485-
To speed up the scanning process, you can choose to scan only a specific area/region.
486-
487-
```javascript
488-
let settings = await scanner.getRuntimeSettings();
489-
/*
490-
* The following code shrinks the decoding region by 25% on all sides
491-
*/
492-
settings.region.regionMeasuredByPercentage = 1;
493-
settings.region.regionLeft = 25;
494-
settings.region.regionTop = 25;
495-
settings.region.regionRight = 75;
496-
settings.region.regionBottom = 75;
497-
await scanner.updateRuntimeSettings(settings);
498-
```
499-
500-
[Try in JSFiddle](https://jsfiddle.net/DynamsoftTeam/taykq592/)
501-
502-
### Show internal logs
503-
504-
Include the following in your code to print internal logs in the console.
505-
506-
```javascript
507-
Dynamsoft.DBR.BarcodeReader._onLog = console.log;
508-
```
509-
510-
### Set mode arguments
511-
512-
To precisely control a mode, you can adjust its specific parameters.
513-
514-
```javascript
515-
let settings = await scanner.getRuntimeSettings();
516-
517-
/*
518-
* The following code sets the sensitivity of the TextureDetectionModes to 9
519-
*/
520-
521-
settings.furtherModes.textureDetectionModes = [
522-
Dynamsoft.DBR.EnumTextureDetectionMode.TDM_GENERAL_WIDTH_CONCENTRATION, 0, 0, 0, 0, 0, 0, 0
523-
];
524-
525-
await scanner.updateRuntimeSettings(settings);
526-
// The 2nd parameter 0 specifies the first mode of TextureDetectionModes, which is "Dynamsoft.DBR.EnumTextureDetectionMode.TDM_GENERAL_WIDTH_CONCENTRATION" in this case.
527-
await scanner.setModeArgument("TextureDetectionModes", 0, "Sensitivity", "9");
528-
```
529-
530-
### Display the intermediate result images or the original canvas
531-
532-
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.
533-
534-
The method `getOriginalImageInACanvas()` returns a canvas which holds the image to be passed to the barcode reader engine for decoding.
535-
536-
> *NOTE*
537-
>
538-
> 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.
539-
>
540-
> 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()` .
541-
542-
The following shows how to display these images on the page
543-
544-
```html
545-
<div id='scannerV' style="width:50vw;height:50vh"></div>
546-
<div id='cvses'></div>
547-
```
548-
549-
```javascript
550-
(async () => {
551-
let scanner = await Dynamsoft.DBR.BarcodeScanner.createInstance();
552-
/* The default of `_bUseWebgl` is true which means the intermediate result for
553-
IRT_ORIGINAL_IMAGE will be one that has been preprocessed by WebGL */
554-
scanner._bUseWebgl = false;
555-
document.getElementById('scannerV').appendChild(scanner.getUIElement());;
556-
await scanner.updateRuntimeSettings('balance');
557-
let rs = await scanner.getRuntimeSettings();
558-
rs.intermediateResultTypes = 1;
559-
await scanner.updateRuntimeSettings(rs);
560-
scanner.onUnduplicatedRead = async (txt, result) => {
561-
try {
562-
let cvss = await scanner.getIntermediateCanvas();
563-
for (let cvs of cvss) {
564-
document.getElementById('cvses').appendChild(cvs);
565-
}
566-
scanner.destroy();
567-
} catch (ex) {
568-
console.error(ex);
569-
}
570-
};
571-
await scanner.show();
572-
})();
573-
```
483+
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).
574484

575485
## How to Upgrade
576486

577-
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).
487+
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).
578488

579489
## FAQ
580490

@@ -602,3 +512,10 @@ To make sure your web application can access the camera, please configure your w
602512
- IIS: [Create a Self Signed Certificate in IIS](https://aboutssl.org/how-to-create-a-self-signed-certificate-in-iis/)
603513
- Tomcat: [Setting Up SSL on Tomcat in 5 minutes](https://dzone.com/articles/setting-ssl-tomcat-5-minutes)
604514
- Node.js: [npm tls](https://nodejs.org/docs/v0.4.1/api/tls.html)
515+
516+
### Accounting for newline characters in the barcode result
517+
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.
518+
519+
There are two ways in which you can resolve this:
520+
1. Wrap the element used to display the result in a `<pre>` element.
521+
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)