Get Barcode Type and Encoded Data
Contents
[
Hide
]
Decode Barcode Type and Data
To retrieve the data encoded in a barcode and determine its type, the class BarCodeResult provides the key fields:
The following code sample shows how to extract the data and barcode type from a sample barcode image (in this case, a QR Code).
// Create a QR barcode
var gen = new BarCodeInstance.BarcodeGenerator("QR", "Åspóse.Barcóde©");
gen.Parameters.Barcode.XDimension = "4px";
document.getElementById("img").src = gen.GenerateBarCodeImage(); // Display QR code image
// Recognize the QR barcode from the image
var reader = new BarCodeInstance.BarCodeReader(gen.GenerateBarCodeImage(), "QR");
reader.ReadBarCodes();
for (var i = 0; i < reader.FoundCount; i++) {
const result = reader.FoundBarCodes(i);
console.log(`CodeText: ${result.CodeText}`);
console.log(`CodeType: ${result.CodeType}`);
}
gen.delete();
reader.delete();