Specify Barcode Formats
There are two ways to configure barcode formats:
- Configure formats in code.
- Configure formats together with other settings in the template.
Configure Formats in Your Code
Specify barcode formats using a combined value of DSBarcodeFormat.
- Use bitwise OR (
|) to combine multiple formats. DSBarcodeFormatDefaultincludes all common formats (DSBarcodeFormatOneD,DSBarcodeFormatGS1Databar,DSBarcodeFormatPDF417,DSBarcodeFormatQRCode,DSBarcodeFormatDataMatrix,DSBarcodeFormatAztec,DSBarcodeFormatMaxiCode,DSBarcodeFormatMicroQR,DSBarcodeFormatMicroPDF417, andDSBarcodeFormatGS1Composite).- Use
DSBarcodeFormatAllto enable all supported formats. - Use group values like
DSBarcodeFormatOneDwhen appropriate.
BarcodeScanner API
BarcodeScannerConfig.barcodeFormats
Code Snippet
- Objective-C
- Swift
DSBarcodeScannerConfig *config = [[DSBarcodeScannerConfig alloc] init]; config.barcodeFormats = DSBarcodeFormatOneD | DSBarcodeFormatQRCode;let config = BarcodeScannerConfig() config.barcodeFormats = [.oneD, .qrCode]
Related APIs
Configure Formats in a Template
Barcode formats are specified in BarcodeFormatIds under BarcodeReaderTaskSettingOptions. For example:
{
"CaptureVisionTemplates": [
{
"ImageROIProcessingNameArray": [ "ROI_2D" ],
"Name": "ReadCommon2D"
}
],
"TargetROIDefOptions": [
{
"Name": "ROI_2D",
"TaskSettingNameArray": [ "Task_2D" ]
}
],
"BarcodeReaderTaskSettingOptions": [
{
"Name": "Task_2D",
"BarcodeFormatIds": [ "BF_QR_CODE", "BF_DATAMATRIX", "BF_PDF417", "BF_MAXICODE" ],
"SectionArray": [
{
"Section": "ST_BARCODE_LOCALIZATION",
"ImageParameterName": "ip"
},
{
"Section": "ST_BARCODE_DECODING",
"ImageParameterName": "ip"
}
]
}
],
"ImageParameterOptions": [
{
"Name": "ip"
}
]
}
For common formats, you can download and use the preset templates below:
| Barcode Format(s) | Template |
|---|---|
| EAN13, EAN8, UPC_A, UPC_E, GS1 Databar | ReadOneDRetail.json |
| Code128, Code39, ITF, Codabar, MSI Code | ReadOneDIndustrial.json |
| QR Code | ReadQR.json |
| Data Matrix | ReadDataMatrix.json |
| PDF417 | ReadPDF417.json |
| Aztec | ReadAztec.json |
| QR Code, Data Matrix, PDF417 | ReadCommon2D.json |
| DotCode | ReadDotCode.json |