Add-On / Extension Codes

The Scandit SDK supports add-on codes (also known as Extension Codes) for EAN-8, EAN-13, UPC-A and UPC-E codes. These codes encode additional product data like an issue number, date or price. There is a two (EAN-2) and a five digit (EAN-5) version.

ean13 with two digit add-on code
ean13 with five digit add-on code







Configuring the SDK

To be able to scan add-on code the maximum number of codes per frame has to be set to 2 (or larger). The symbology of the main code (e.g. EAN-13) and the expected add-on symbology (e.g. five digit) have to be enabled individually in the SDK settings. The data of the two scanned codes is returned as two separate results. Be aware that it can happen that only the main code is found in a particular frame. Isolated extension codes are never returned as a result.

Android

Settings setup for EAN-13 codes with a 5 digit add-on on Android:

ScanSettings settings = ScanSettings.create();
settings.setSymbologyEnabled(Barcode.SYMBOLOGY_EAN13, true);
settings.setSymbologyEnabled(Barcode.SYMBOLOGY_FIVE_DIGIT_ADD_ON, true);
settings.setMaxNumberOfCodesPerFrame(2);
settings.setCodeDuplicateFilter(0);
settings.setCodeCachingDuration(0);
BarcodePicker picker = new BarcodePicker(this, settings);

The Add-On code and the main code (EAN13, EAN8, UPCA, or UPCE) are returned as two separate codes and the result needs to be combined in the didScan callback. A possible implementation of the didScan callback can look like this:

@Override
public void didScan(ScanSession session) {
session.pauseScanning();
// will either contain 1 or 2 codes.
List<Barcode> codes = session.getNewlyRecognizedCodes();
// check if there is an add-on code
Barcode addOnCode = null;
Barcode otherCode = null;
for (Barcode code : codes) {
if (code.getSymbology() == Barcode.SYMBOLOGY_FIVE_DIGIT_ADD_ON ||
code.getSymbology() == Barcode.SYMBOLOGY_TWO_DIGIT_ADD_ON) {
addOnCode = code;
} else {
otherCode = code;
}
}
String data;
if (addOnCode != null && otherCode != null) {
// combine the two data strings
data = String.format("%1$s-%2$s", otherCode.getData(), addOnCode.getData());
} else {
data = otherCode.getData();
}
// do something with data...
}

iOS

Settings setup for EAN-13 codes with a 5 digit add-on on iOS:

NSSet *symbologiesToEnable = [NSSet setWithObjects:
@(SBSSymbologyEAN13) ,
@(SBSSymbologyFiveDigitAddOn), nil];
[settings enableSymbologies:symbologiesToEnable];
settings.maxNumberOfCodesPerFrame = 2;
settings.codeDuplicateFilter = 0;
settings.codeCachingDuration = 0;
picker = [[SBSBarcodePicker alloc] initWithSettings:settings];

The Add-On code and the main code (EAN13, EAN8, UPCA, or UPCE) are returned as two separate codes and the result needs to be combined in the didScan callback. A possible implementation of the didScan callback can look like this:

- (void)barcodePicker:(SBSBarcodePicker *)picker
didScan:(SBSScanSession *)session {
SBSCode *addOnCode = nil;
SBSCode *otherCode = nil;
NSArray* recognized = session.newlyRecognizedCodes;
for (SBSCode *code in recognized) {
if (code.symbology == SBSSymbologyTwoDigitAddOn ||
code.symbology == SBSSymbologyFiveDigitAddOn) {
addOnCode = code;
} else {
otherCode = code;
}
}
NSString *data = nil;
if (addOnCode != nil && otherCode != nil) {
data = [NSString stringWithFormat:@"%@ - %@", otherCode.data, addOnCode.data];
} else {
data = otherCode.data;
}
// do something with data...
}