From 9e140c7601fb2aab6769cafc95efe67904e492df Mon Sep 17 00:00:00 2001 From: Doby2333 Date: Mon, 16 Dec 2024 11:29:13 +0800 Subject: [PATCH] Add more information on FAQ Page regarding Addon Codes --- faq/general/how-to-scan-ean-upc-with-addon.md | 48 +++++++++++++++---- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/faq/general/how-to-scan-ean-upc-with-addon.md b/faq/general/how-to-scan-ean-upc-with-addon.md index 9e5f19a7..62934e56 100644 --- a/faq/general/how-to-scan-ean-upc-with-addon.md +++ b/faq/general/how-to-scan-ean-upc-with-addon.md @@ -11,28 +11,42 @@ permalink: /faq/general/how-to-scan-ean-upc-with-addon.html [<< Back to FAQ index](index.md) -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. +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. -Dynamsoft Barcode Reader (DBR) does not enable reading such AddOn Codes with its default templates. +Dynamsoft Barcode Reader (DBR) does not enable reading such AddOn Codes by default. ![EAN-13 + EAN-5 on a book](https://www.dynamsoft.com/codepool/img/2024/10/add-on/ean_13.jpg) ![UPC-E + UPC-2 on a magazine](https://www.dynamsoft.com/codepool/img/2024/10/add-on/upc_e.jpg) -In order to read these types of barcodes, the property `EnableAddOnCode` in `BarcodeFormatSpecificationOptions` arrays must be set to `1`. +To enable AddOn Code scanning, the property `EnableAddOnCode` in the `BarcodeFormatSpecificationOptions` array must be set to 1. -### Using JSON Templates +If you want to limit the Dynamsoft Barcode Reader to only decode UPC and EAN codes with AddOn Codes, consider the following additional configurations: +1. **Regular Expression Filtering:** Use `BarcodeTextRegExPattern` to exclude results without AddOn Codes. +2. **Barcode Format Restriction:** Restrict the barcode formats to EAN and UPC only by setting `BarcodeFormatIds`. -You can find all occurrences of `EnableAddOnCode` in your existing template file and set their values to `1` instead of the default `0`. +### Using JSON Templates +Modify all of the `EnableAddOnCode` property in your template file by setting its value to `1`: ```json { - "BarcodeFormatSpecificationOptions": [ + "BarcodeFormatSpecificationOptions": + [ { - "EnableAddOnCode": 1, // 1 to Enable AddOn Codes + "EnableAddOnCode": 1, // Enable AddOn Codes "Name": "bfs1", + // (OPTIONAL) Apply Regular Expression Filtering + // Exclude All Other Results Without Addon Codes + "BarcodeTextRegExPattern" : "\\d+-\\d+", ... }, ... + ], + "BarcodeReaderTaskSettingOptions" : + [ + { // (OPTIONAL) Restrict Formats to EAN and UPC Only + "BarcodeFormatIds" : + [ "BF_EAN_8", "BF_EAN_13", "BF_UPC_A", "BF_UPC_E" ], + } ], ... } @@ -41,11 +55,29 @@ You can find all occurrences of `EnableAddOnCode` in your existing template file ### Using JavaScript Code ```javascript -let settings = await cvRouter.outputSettings(); +let settings = await cvRouter.outputSettings(); // Retrieve the runtime settings let formatOptionsArray = settings.BarcodeFormatSpecificationOptions; for (let index = 0; index < formatOptionsArray.length; index++) { const options = formatOptionsArray[index]; + // Enable AddOn Codes options["EnableAddOnCode"] = 1; + // (OPTIONAL) Apply Regular Expression Filtering + // Exclude Results Without AddOn Codes + options["BarcodeTextRegExPattern"] = "\\d+-\\d+"; } + +// -------------------- (OPTIONAL) ------------------------------------------- +// Restrict Expected Barcode Formats to EAN and UPC Only +let barcodeOptionsArray = settings.BarcodeReaderTaskSettingOptions; +for (let index = 0; index < barcodeOptionsArray.length; index++) { + const options = barcodeOptionsArray[index]; + options["BarcodeFormatIds"] = ["BF_EAN_8", "BF_EAN_13", "BF_UPC_A", "BF_UPC_E"]; +} +// --------------------------------------------------------------------------- + +await cvRouter.initSettings(settings); // Apply the modified settings ``` +### Sample Code + +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). \ No newline at end of file