Skip to content

Commit 947bc50

Browse files
Merge pull request #783 from lyzhang0113/main
Add more information on FAQ Page regarding Addon Codes
2 parents 9ff684d + 9e140c7 commit 947bc50

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

faq/general/how-to-scan-ean-upc-with-addon.md

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,42 @@ permalink: /faq/general/how-to-scan-ean-upc-with-addon.html
1111

1212
[<< Back to FAQ index](index.md)
1313

14-
UPC and EAN are barcode formats commonly used for product identification. Both UPC and EAN codes can have supplemental 2-digit or 5-digit barcodes, typically found on the right side of the main code.
14+
UPC and EAN are barcode formats commonly used for product identification. These formats can include supplemental 2-digit or 5-digit barcodes (known as AddOn Codes), typically found on the right side of the main barcode. These AddOn Codes are often used for magazines, books, or other products to encode additional information like pricing or issue numbers.
1515

16-
Dynamsoft Barcode Reader (DBR) does not enable reading such AddOn Codes with its default templates.
16+
Dynamsoft Barcode Reader (DBR) does not enable reading such AddOn Codes by default.
1717

1818
![EAN-13 + EAN-5 on a book](https://www.dynamsoft.com/codepool/img/2024/10/add-on/ean_13.jpg)
1919
![UPC-E + UPC-2 on a magazine](https://www.dynamsoft.com/codepool/img/2024/10/add-on/upc_e.jpg)
2020

21-
In order to read these types of barcodes, the property `EnableAddOnCode` in `BarcodeFormatSpecificationOptions` arrays must be set to `1`.
21+
To enable AddOn Code scanning, the property `EnableAddOnCode` in the `BarcodeFormatSpecificationOptions` array must be set to 1.
2222

23-
### Using JSON Templates
23+
If you want to limit the Dynamsoft Barcode Reader to only decode UPC and EAN codes with AddOn Codes, consider the following additional configurations:
24+
1. **Regular Expression Filtering:** Use `BarcodeTextRegExPattern` to exclude results without AddOn Codes.
25+
2. **Barcode Format Restriction:** Restrict the barcode formats to EAN and UPC only by setting `BarcodeFormatIds`.
2426

25-
You can find all occurrences of `EnableAddOnCode` in your existing template file and set their values to `1` instead of the default `0`.
27+
### Using JSON Templates
2628

29+
Modify all of the `EnableAddOnCode` property in your template file by setting its value to `1`:
2730
```json
2831
{
29-
"BarcodeFormatSpecificationOptions": [
32+
"BarcodeFormatSpecificationOptions":
33+
[
3034
{
31-
"EnableAddOnCode": 1, // 1 to Enable AddOn Codes
35+
"EnableAddOnCode": 1, // Enable AddOn Codes
3236
"Name": "bfs1",
37+
// (OPTIONAL) Apply Regular Expression Filtering
38+
// Exclude All Other Results Without Addon Codes
39+
"BarcodeTextRegExPattern" : "\\d+-\\d+",
3340
...
3441
},
3542
...
43+
],
44+
"BarcodeReaderTaskSettingOptions" :
45+
[
46+
{ // (OPTIONAL) Restrict Formats to EAN and UPC Only
47+
"BarcodeFormatIds" :
48+
[ "BF_EAN_8", "BF_EAN_13", "BF_UPC_A", "BF_UPC_E" ],
49+
}
3650
],
3751
...
3852
}
@@ -41,11 +55,29 @@ You can find all occurrences of `EnableAddOnCode` in your existing template file
4155
### Using JavaScript Code
4256

4357
```javascript
44-
let settings = await cvRouter.outputSettings();
58+
let settings = await cvRouter.outputSettings(); // Retrieve the runtime settings
4559
let formatOptionsArray = settings.BarcodeFormatSpecificationOptions;
4660
for (let index = 0; index < formatOptionsArray.length; index++) {
4761
const options = formatOptionsArray[index];
62+
// Enable AddOn Codes
4863
options["EnableAddOnCode"] = 1;
64+
// (OPTIONAL) Apply Regular Expression Filtering
65+
// Exclude Results Without AddOn Codes
66+
options["BarcodeTextRegExPattern"] = "\\d+-\\d+";
4967
}
68+
69+
// -------------------- (OPTIONAL) -------------------------------------------
70+
// Restrict Expected Barcode Formats to EAN and UPC Only
71+
let barcodeOptionsArray = settings.BarcodeReaderTaskSettingOptions;
72+
for (let index = 0; index < barcodeOptionsArray.length; index++) {
73+
const options = barcodeOptionsArray[index];
74+
options["BarcodeFormatIds"] = ["BF_EAN_8", "BF_EAN_13", "BF_UPC_A", "BF_UPC_E"];
75+
}
76+
// ---------------------------------------------------------------------------
77+
78+
await cvRouter.initSettings(settings); // Apply the modified settings
5079
```
5180

81+
### Sample Code
82+
83+
You may also find it helpful to explore our [blog post on scanning EAN/UPC and AddOn codes with JavaScript](https://www.dynamsoft.com/codepool/scan-ean-upc-and-its-add-on-javascript.html).

0 commit comments

Comments
 (0)