Skip to content

Commit 8b3dbb8

Browse files
authored
Merge pull request #433 from yqz5625/main
Update enable-supported-barcode-format.md
2 parents 12c3498 + 18a7953 commit 8b3dbb8

File tree

1 file changed

+73
-10
lines changed

1 file changed

+73
-10
lines changed

programming/javascript/faq/enable-supported-barcode-format.md

Lines changed: 73 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,18 @@ Explicitly enable **only the barcode formats covered by your license** in your c
2424

2525
2. **Configure Barcode Formats**
2626
Update your code to explicitly enable **only the licensed formats**.
27-
- Example for Enabling **QR Code Only**:
28-
27+
- Example for Enabling **Multiple Formats**:
28+
Use bitwise OR (|) to combine formats.
29+
<div class="sample-code-prefix"></div>
30+
>- Javascript
31+
>- Objective-C
32+
>- Swift
33+
>- Android
34+
>- Python
35+
>- C++
36+
>- C#
37+
>
38+
>1.
2939
```javascript
3040
let settings = await router.getSimplifiedSettings("ReadSingleBarcode");
3141
// Enable QR Code only
@@ -34,14 +44,67 @@ Explicitly enable **only the barcode formats covered by your license** in your c
3444
await router.updateSettings("ReadSingleBarcode", settings);
3545
await router.startCapturing("ReadSingleBarcode");
3646
```
37-
38-
- Example for Enabling **Multiple Formats**:
39-
40-
Use bitwise OR (|) to combine formats.
41-
```javascript
42-
// Enable QR Code and 1D
43-
settings.barcodeSettings.barcodeFormatIds =
44-
Dynamsoft.DBR.EnumBarcodeFormat.BF_QR_CODE | Dynamsoft.DBR.EnumBarcodeFormat.BF_ONED;
47+
2.
48+
```objc
49+
DSBarcodeScannerConfig *config = [[DSBarcodeScannerConfig alloc] init];
50+
config.barcodeFormats = DSBarcodeFormatQRCode;
51+
```
52+
3.
53+
```swift
54+
let config = BarcodeScannerConfig()
55+
config.barcodeFormats = [.qrCode]
56+
```
57+
4.
58+
```java
59+
try {
60+
// Obtain current runtime settings. `cvr` is an instance of `CaptureVisionRouter`.
61+
// Here we use `EnumPresetTemplate.PT_READ_BARCODES` as an example. You can change it to your own template name or the name of other preset template.
62+
SimplifiedCaptureVisionSettings captureVisionSettings = cvr.getSimplifiedSettings(EnumPresetTemplate.PT_READ_BARCODES);
63+
captureVisionSettings.barcodeSettings.barcodeFormatIds = EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_ONED;
64+
// Update the settings. Remember to specify the same template name you used when getting the settings.
65+
cvr.updateSettings(EnumPresetTemplate.PT_READ_BARCODES, captureVisionSettings);
66+
} catch (CaptureVisionRouterException e) {
67+
e.printStackTrace();
68+
}
69+
```
70+
5.
71+
```python
72+
cvr_instance = CaptureVisionRouter()
73+
# Obtain current runtime settings of `CCaptureVisionRouter` instance.
74+
err_code, err_str, settings = cvr_instance.get_simplified_settings(EnumPresetTemplate.PT_READ_BARCODES.value)
75+
# Specify the barcode formats by enumeration values.
76+
# Use "|" to enable multiple barcode formats at one time.
77+
settings.barcode_settings.barcode_format_ids = EnumBarcodeFormat.BF_QR_CODE.value | EnumBarcodeFormat.BF_ONED.value
78+
# Update the settings.
79+
err_code, err_str = cvr_instance.update_settings(EnumPresetTemplate.PT_READ_BARCODES.value, settings)
80+
```
81+
6.
82+
```c++
83+
char szErrorMsg[256] = {0};
84+
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
85+
CCaptureVisionRouter* cvr = new CCaptureVisionRouter;
86+
SimplifiedCaptureVisionSettings settings;
87+
cvr->GetSimplifiedSettings(CPresetTemplate::PT_READ_BARCODES, &settings);
88+
// Specify the barcode formats by enumeration values.
89+
// Use "|" to enable multiple barcode formats at one time.
90+
settings.barcodeSettings.barcodeFormatIds = BF_QR_CODE | BF_ONED;
91+
// Update the settings.
92+
cvr->UpdateSettings(CPresetTemplate::PT_READ_BARCODES, &settings, szErrorMsg, 256);
93+
```
94+
7.
95+
```csharp
96+
using (CaptureVisionRouter cvr = new CaptureVisionRouter())
97+
{
98+
SimplifiedCaptureVisionSettings settings;
99+
string errorMsg;
100+
// Obtain current runtime settings of `CCaptureVisionRouter` instance.
101+
cvr.GetSimplifiedSettings(PresetTemplate.PT_READ_BARCODES, out settings);
102+
// Specify the barcode formats by enumeration values.
103+
// Use "|" to enable multiple barcode formats at one time.
104+
settings.barcodeSettings.barcodeFormatIds = (ulong)(EnumBarcodeFormat.BF_QR_CODE | EnumBarcodeFormat.BF_ONED);
105+
// Update the settings.
106+
cvr.UpdateSettings(PresetTemplate.PT_READ_BARCODES, settings, out errorMsg);
107+
}
45108
```
46109

47110
4. **Verify Supported Formats**

0 commit comments

Comments
 (0)