new BarcodeReader(image, rectangles, decodeTypes)

Initializes a new instance of the BarCodeReader

Parameters

Name Type Optional Description

image

 

 

encoded as base64 string

rectangles

 

 

array of object by type Rectangle

decodeTypes

 

 

the array of objects by DecodeType

Methods

close()

Closes barcode reader.

containsAny()

Determines whether any of the given decode types is included into

Parameter

Name Type Optional Description

...decodeTypes

 

 

Types to verify.

Returns

bool Value is a true if any types are included into.

exportToXml(xmlFile)

Exports BarCode properties to the xml-file specified

Parameter

Name Type Optional Description

xmlFile

 

 

The name for the file

Returns

Whether or not export completed successfully. Returns True in case of success; False Otherwise

getAngle()

Gets the angle of the barcode (0-360).

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getRegion().getAngle() instead.
Returns

The angle for barcode (0-360).

getCheckSum()

Gets the checksum for 1D barcodes.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getOneD().getCheckSum() instead.
Returns

The checksum for 1D barcode.

getChecksumValidation()

Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies This sample shows influence of ChecksumValidation on recognition quality and results

let generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128"); generator.save("test.png"); let reader = new BarCodeReader("test.png", null, DecodeType.EAN_13); //checksum disabled reader.setChecksumValidation(ChecksumValidation.OFF); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); console.log("BarCode Value: " + result.getExtended().getOneD().getValue()); console.log("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); }); let reader = new BarCodeReader("test.png", null, DecodeType.EAN_13); //checksum enabled reader.setChecksumValidation(ChecksumValidation.ON); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); console.log("BarCode Value: " + result.getExtended().getOneD().getValue()); console.log("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); }); The checksum validation flag.

getCode128DataPortions()

Gets Code128DataPortion instance for recognized Code128 barcode

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getCode128().getCode128DataPortions() instead.
Returns

The array of Code128DataPortion objects.

getCodeBytes()

Gets the encoded code bytes.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getCodeBytes() instead.
Returns

The code bytes of the barcode.

getCodeText()

Gets the code text. Text will not contain the checksum for 1D barcode types, which support the checksum. Please use GetCodeText(true) method to get result with checksum.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getCodeText() instead.
Returns

The code text of the barcode.

getCodeType()

Gets the barcode type.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getCodeType() instead.
Returns

The type information of the recognized barcode.

getCodeTypeName()

Gets the name of the barcode type.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getCodeTypeName() instead.
Returns

The type name of the recognized barcode.

getCustomerInformationInterpretingType()

Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

getDetectEncoding()

A flag which force engine to detect codetext encoding for Unicode codesets. This sample shows how to detect text encoding on the fly if DetectEncoding is enabled image = "image.png"; let generator = new BarcodeGenerator(EncodeTypes.QR, "пїЅпїЅпїЅпїЅпїЅ")) generator.getParameters().getBarcode().getQR().setCodeTextEncoding("UTF-8"); generator.save(image, BarCodeImageFormat.getPng()); //detects encoding for Unicode codesets is enabled let reader = new BarCodeReader(image, null, DecodeType.QR); reader.setDetectEncoding(true); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); //detect encoding is disabled let reader = new BarCodeReader(image, null, DecodeType.QR); reader.setDetectEncoding(false); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

getFileName()

Gets file name which was assigned by user

Returns

file name

getFoundBarCodes()

Gets recognized BarCodeResult array This sample shows how to read barcodes with BarCodeReader

let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); reader.readBarCodes(); for(let i = 0; reader.getFoundCount() > i; ++i) console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());

Value: The recognized BarCodeResult array

getFoundCount()

Gets recognized barcodes count


This sample shows how to read barcodes with BarCodeReader let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); reader.readBarCodes(); for(let i = 0; reader.getFoundCount() > i; ++i) console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText()); Value: The recognized barcodes count

getIsDeniable()

Checks the deniable recognition. Such recognition might occur in QualitySettings.getMaxBarcodes() mode decoding or use QualitySettings.getAllowIncorrectBarcodes()

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getConfidence() instead.
Returns

True if the deniable recognition was read.

getMacroPdf417FileID()

Gets the file ID of the barcode, only available with MacroPdf417.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getPdf417().getMacroPdf417FileID() instead.
Returns

The file ID for MacroPdf417

getMacroPdf417SegmentID()

Gets the segment ID of the barcode,only available with MacroPdf417.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getPdf417().getMacroPdf417SegmentID() instead.
Returns

The segment ID of the barcode.

getMacroPdf417SegmentsCount()

Gets macro pdf417 barcode segments count. Default value is -1.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getPdf417().getMacroPdf417SegmentsCount() instead.
Returns

The segments count.

getQRStructuredAppendModeBarCodeIndex()

Gets the index of the QR structured append mode barcode. Index starts from 0. DEFAULT value is -1.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getQR().getQRStructuredAppendModeBarCodeIndex() instead.
Returns

The index of the QR structured append mode barcode.

getQRStructuredAppendModeBarCodesQuantity()

Gets the QR structured append mode barcodes quantity. Default value is -1.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getQR().getQRStructuredAppendModeBarCodesQuantity() instead.
Returns

The quantity of the QR structured append mode barcode.

getQRStructuredAppendModeParityData()

Gets the QR structured append mode parity data. Default value is -1.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getExtended().getQR().getQRStructuredAppendModeParityData() instead.
Returns

The QR structured append mode parity data.

getQualitySettings()

QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.

This sample shows how to use QualitySettings with BarCodeReader

let reader = new BarCodeReader("test.png", null, null); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); //normal quality mode is set by default reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); QualitySettings to configure recognition quality and speed.

getRecognitionQuality()

Gets the recognition quality. Works for 1D and postal barcodes.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getReadingQuality() instead.
Returns

The recognition quality percent.

getRegion()

Gets the barcode region.

Deprecated
This method is obsolete. Use BarCodeReader.getFoundBarCodes()[].getRegion() instead.
Returns

The region of the recognized barcode.

getStripFNC()

Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.

This sample shows how to strip FNC characters

let generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754"); generator.save("test.png"); let reader = new BarCodeReader("test.png", null, DecodeType.CODE_128); //StripFNC disabled reader.setStripFNC(false); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, DecodeType.CODE_128); //StripFNC enabled reader.setStripFNC(true); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

getTimeout()

Gets the timeout of recognition process in milliseconds.

let reader = new BarCodeReader("test.png", null, null); reader.setTimeout(5000); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

Returns

The timeout.

read()

Reads barcode from the image.

Detect AllSupportedTypes

full_path = "test.png"; let reader = new BarcodeReader(full_path, null, null); while(reader.read()) { console.log(reader.getCodeText(false)); console.log(reader.getCodeTypeName()); } reader.close();

Returns

True if the next barcode was read successfully; false if there are no more nodes to read.

readBarCodes()

Reads BarCodeResult from the image. This sample shows how to read barcodes with BarCodeReader let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); reader.readBarCodes(); for(let i = 0; reader.getFoundCount() > i; ++i) console.log("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText());

Returns

Returns array of recognized {@code BarCodeResult}s on the image. If nothing is recognized, zero array is returned.

setBarCodeImage(value, ...areas)

Sets bitmap image and areas for recognition. Must be called before ReadBarCodes() method. This sample shows how to detect Code39 and Code128 barcodes. let bmp = "test.png"; let reader = new BarCodeReader(); reader.setBarCodeReadType([ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); var img = new Image(); img.src = 'path_to_image'; width = img.width; height = img.height; reader.setBarCodeImage(bmp, new Rectangle[] { new Rectangle(0, 0, width, height) }); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode Type: " + result.getCodeTypeName()); console.log("BarCode CodeText: " + result.getCodeText()); });

Parameters

Name Type Optional Description

value

 

 

The bitmap image for recognition.

areas

 

 

areas list for recognition

Value can be repeated.

Throws

BarcodeException

setBarCodeReadType(...types)

Sets SingleDecodeType type array for recognition. Must be called before readBarCodes() method. This sample shows how to detect Code39 and Code128 barcodes. let reader = new BarCodeReader(); reader.setBarCodeReadType([ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); reader.setBarCodeImage("test.png"); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode Type: " + result.getCodeTypeName()); console.log("BarCode CodeText: " + result.getCodeText()); });

Parameter

Name Type Optional Description

types

 

 

The SingleDecodeType type array to read.

Value can be repeated.

setChecksumValidation()

Enable checksum validation during recognition for 1D barcodes. Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies

This sample shows influence of ChecksumValidation on recognition quality and results

let generator = new BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128"); generator.save("test.png"); let reader = new BarCodeReader("test.png", null, DecodeType.EAN_13); //checksum disabled reader.setChecksumValidation(ChecksumValidation.OFF); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); console.log("BarCode Value: " + result.getExtended().getOneD().getValue()); console.log("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); }); let reader = new BarCodeReader("test.png", null, DecodeType.EAN_13); //checksum enabled reader.setChecksumValidation(ChecksumValidation.ON); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); console.log("BarCode Value: " + result.getExtended().getOneD().getValue()); console.log("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum()); }); The checksum validation flag.

setCustomerInformationInterpretingType()

Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

setDetectEncoding()

A flag which force engine to detect codetext encoding for Unicode codesets. This sample shows how to detect text encoding on the fly if DetectEncoding is enabled let image = "image.png"; let generator = new BarcodeGenerator(EncodeTypes.QR, "пїЅпїЅпїЅпїЅпїЅ"); generator.getParameters().getBarcode().getQR().setCodeTextEncoding("UTF-8"); generator.save(image, BarCodeImageFormat.getPng()); //detects encoding for Unicode codesets is enabled let reader = new BarCodeReader(image, null, DecodeType.QR); reader.setDetectEncoding(true); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); //detect encoding is disabled let reader = new BarCodeReader(image, null, DecodeType.QR); reader.setDetectEncoding(true); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

setQualitySettings()

QualitySettings allows to configure recognition quality and speed manually. You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality, HighQuality, MaxBarCodes or you can manually configure separate options. Default value of QualitySettings is NormalQuality.

This sample shows how to use QualitySettings with BarCodeReader let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); //normal quality mode is set by default reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ]); //set high performance mode reader.setQualitySettings(QualitySettings.getHighPerformance()); //set separate options reader.getQualitySettings().setAllowMedianSmoothing(true); reader.getQualitySettings().setMedianSmoothingWindowSize(5); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); QualitySettings to configure recognition quality and speed.

setStripFNC()

Strip FNC1, FNC2, FNC3 characters from codetext. Default value is false.

This sample shows how to strip FNC characters

let generator = new BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754"); generator.save("test.png"); let reader = new BarCodeReader("test.png", null, DecodeType.CODE_128); //StripFNC disabled reader.setStripFNC(false); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); }); let reader = new BarCodeReader("test.png", null, DecodeType.CODE_128); //StripFNC enabled reader.setStripFNC(true); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

setTimeout(value)

Sets the timeout of recognition process in milliseconds.

let reader = new BarCodeReader("test.png", null, null); reader.setTimeout(5000); reader.readBarCodes().forEach(function(result, i, results) { console.log("BarCode CodeText: " + result.getCodeText()); });

Parameter

Name Type Optional Description

value

 

 

The timeout.