Skip to main content

Barcode Reading

AmbirScan Web Connect can detect and decode barcodes from scanned images.

note

Barcode decoding is a premium feature that requires additional licensing. Without a license, barcode results will not be returned. Contact Ambir for pricing.

Enabling Barcode Detection​

Pass barcodeReadingEnabled: true in your scan parameters. If you know which barcode type you are scanning, say so with barcodeFormats — it is the biggest single speed-up available:

const images = await scanner.scan({
resolution: 300,
colorMode: 'Color',
barcodeReadingEnabled: true,
barcodeFormats: ['Pdf417'] // optional: only look for PDF417
});

Choosing Symbologies​

By default every supported symbology is searched on every page. Each one you don't need costs extra decode passes, so two optional parameters let you narrow the search:

ParameterTypeDefaultDescription
barcodeFormatsstring[][] (all)Only look for these symbologies. Use the names in the first column of Supported Barcode Formats.
barcodeStopAfterFirstbooleanfalseStop reading a page as soon as one barcode is found
// Driver's licence: one PDF417 barcode per card
const images = await scanner.scan({
barcodeReadingEnabled: true,
barcodeFormats: ['Pdf417'],
barcodeStopAfterFirst: true
});

// Shipping labels that carry both a QR code and a Code 128
const labels = await scanner.scan({
barcodeReadingEnabled: true,
barcodeFormats: ['QrCode', 'Code128']
});
  • Speed: narrowing barcodeFormats to the one symbology you expect, or setting barcodeStopAfterFirst, can cut a driver's-licence page from over a dozen decode passes to one.
  • Accuracy: restricting formats also removes false positives — for example, a plain page misread as a short UPC_E code.
  • Names are matched case-insensitively ('pdf417' works). In scan(), names that aren't recognised are skipped, and if none are recognised every symbology is searched. The REST /api/twain/scan endpoint and auto-scan reject an unrecognised name with HTTP 400 instead.
  • Leave barcodeStopAfterFirst off for pages that carry more than one barcode you need.

Both parameters are optional; omitting them keeps the previous behaviour.

macOS

On macOS, barcodeFormats and barcodeStopAfterFirst are ignored — every symbology is always searched — and the scan still succeeds. Result fields and barcodeType names are the same as on Windows, except that UPC_A is never reported. See Platform Differences.

Reading Barcode Results​

Each scanned image includes a barcodes array:

images.forEach(image => {
if (image.barcodes && image.barcodes.length > 0) {
image.barcodes.forEach(barcode => {
console.log(`Type: ${barcode.barcodeType}`);
console.log(`Text: ${barcode.text}`);
console.log(`Confidence: ${(barcode.confidence * 100).toFixed(0)}%`);

// AAMVA driver's license data (if applicable)
if (barcode.isAamva && barcode.parsedData) {
console.log(`Driver License Data: ${barcode.parsedData}`);
}
});
}
});

Supported Barcode Formats​

Thirteen symbologies are supported. Request them by the name in the first column; results report them by the name in the second column.

barcodeFormats nameResult barcodeTypeKindTypical use
Pdf417PDF_4172DDriver's licences and ID cards, shipping labels
QrCodeQR_CODE2DURLs, tickets, general-purpose data
DataMatrixDATA_MATRIX2DSmall parts marking, pharmaceuticals
AztecAZTEC2DBoarding passes, transit tickets
Code128CODE_1281DHigh-density alphanumeric, shipping and logistics
Code39CODE_391DAlphanumeric, industrial and government
Code93CODE_931DCompact alphanumeric
Ean13EAN_131DRetail products (13-digit)
Ean8EAN_81DRetail products (8-digit)
UpcAUPC_A1DRetail products (12-digit)
UpcEUPC_E1DCompressed UPC
ItfITF1DInterleaved 2 of 5, cartons
CodabarCODABAR1DLibraries, blood banks

AAMVA Driver's License Decoding​

AmbirScan Web Connect includes built-in AAMVA (American Association of Motor Vehicle Administrators) decoding for North American driver's licenses and identification cards. When a PDF_417 barcode from a driver's license is detected, the barcode result includes parsed AAMVA data.

How It Works​

The PDF_417 barcode on the back of North American driver's licenses encodes personal and license data in the AAMVA standard format. AmbirScan Web Connect automatically detects AAMVA-encoded barcodes and parses the structured data.

Barcode Result Fields​

When an AAMVA barcode is detected, the barcode object includes additional fields:

FieldTypeDescription
isAamvabooleantrue if the barcode contains AAMVA-encoded data
parsedDatastringParsed AAMVA data from the driver's license

Example​

const images = await scanner.scan({
resolution: 300,
colorMode: 'Color',
barcodeReadingEnabled: true,
barcodeFormats: ['Pdf417']
});

images.forEach(image => {
image.barcodes?.forEach(barcode => {
if (barcode.isAamva && barcode.parsedData) {
console.log('Driver License Data:', barcode.parsedData);
}
});
});
tip

For best results scanning driver's licenses, use 300 DPI, Color mode and barcodeFormats: ['Pdf417']. The PDF_417 barcode on the back of the license is typically small and dense, and limiting the search to PDF417 is both faster and more reliable than searching every symbology.

Filter Levels​

The barcodeFilterLevel parameter controls how aggressively false positives are filtered:

LevelDescriptionUse Case
LowMinimal validation, may include false positivesWhen you need to catch every possible barcode
NormalBalanced validation (recommended)General use
HighStrict validation, fewer false positivesWhen accuracy is more important than recall
VeryHighMost strict, only high-confidence resultsWhen you need maximum certainty

Windows and macOS apply these levels with different thresholds, so the same level can return slightly different results on each. On macOS, VeryHigh also discards barcodes shorter than six characters. Use the level names exactly as shown.

Best Practices​

  • Resolution: Use 300 DPI for best barcode detection. Lower resolutions may miss small barcodes.
  • Color mode: Grayscale or Color both work well. Black & White may lose detail on damaged barcodes.
  • Multiple barcodes: All barcodes on a page are detected in a single scan — no need to scan multiple times. Leave barcodeStopAfterFirst off in this case.
  • Performance: Barcode detection adds processing time. Only enable it when needed, and pass barcodeFormats whenever you know what you are scanning.