Barcode Detection in Documents

Available on: iOS Android React Native Flutter Cordova .NET MAUI

The Genius Scan SDK can detect and extract barcodes and QR codes from scanned documents. This differs from live barcode scanning as it extracts codes from document images after capture, making it ideal for processing documents that contain embedded codes such as invoices, shipping labels, or tickets.

Implementation

To enable barcode detection in documents, configure the scan flow with the readable codes structured data type and specify which code types to detect.

let configuration = GSKScanFlowConfiguration()

// Enable readable code extraction
configuration.structuredData = [.readableCode]

// Specify which code types to detect
configuration.structuredDataReadableCodeTypes = [
    .qr,
    .ean13,
    .code128,
    .dataMatrix
]

configuration.multiPage = false
configuration.skipPostProcessingScreen = true

// Start scan flow
self.scanFlow = GSKScanFlow(configuration: configuration)
scanFlow.start(from: viewController, onSuccess: { result in
    // Access detected codes
    if let codes = result.scans.first?.structuredDataResult?.readableCodes {
        for code in codes {
            print("Type: \(code.type)")
            print("Value: \(code.value)")
            print("Location: \(code.boundingBox)")
        }
    }
}, failure: { error in
    // Handle error
})

For a complete list of supported code types, see the GSKStructuredDataReadableCodeType in the iOS API documentation.

val configuration = ScanConfiguration().apply {
    // Enable readable code extraction
    structuredData = EnumSet.of(StructuredData.READABLE_CODE)

    // Specify which code types to detect
    structuredDataReadableCodeTypes = EnumSet.of(
        ReadableCode.Type.QR,
        ReadableCode.Type.EAN13,
        ReadableCode.Type.CODE128,
        ReadableCode.Type.DATA_MATRIX
    )

    multiPage = false
}

// Start scan flow
ScanFlow.scanWithConfiguration(activity, configuration)

// Handle result
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    data?.let {
        val result = ScanFlow.getScanResultFromActivityResult(data)

        // Access detected codes
        result.scans?.first()?.structuredDataResult?.readableCodes?.forEach { code ->
            Log.d("Scanner", "Type: ${code.type}")
            Log.d("Scanner", "Value: ${code.value}")
            Log.d("Scanner", "Location: ${code.boundingBox}")
        }
    }
}

For a complete list of supported code types, see the ReadableCode.Type in the Android API documentation.

const configuration = {
  // Enable readable code extraction
  structuredData: ['readableCode'],

  // Specify which code types to detect
  structuredDataReadableCodeTypes: ['qr', 'ean13', 'code128', 'dataMatrix'],

  multiPage: false,
  skipPostProcessingScreen: true
};

// Start scan flow
try {
  const result = await RNGeniusScan.scanWithConfiguration(configuration);

  // Access detected codes
  if (result.scans && result.scans[0].structuredData?.readableCodes) {
    const codes = result.scans[0].structuredData.readableCodes;
    codes.forEach(code => {
      console.log("Type:", code.type);
      console.log("Value:", code.value);
    });
  }
} catch (error) {
  // Handle error
  console.error("Scan failed:", error);
}
var configuration = {
  // Enable readable code extraction
  'structuredData': ['readableCode'],

  // Specify which code types to detect
  'structuredDataReadableCodeTypes': ['qr', 'ean13', 'code128', 'dataMatrix'],

  'multiPage': false,
  'skipPostProcessingScreen': true
};

// Start scan flow
try {
  var result = await FlutterGeniusScan.scanWithConfiguration(configuration);

  // Access detected codes
  if (result['scans'] != null && result['scans'].isNotEmpty) {
    var structuredData = result['scans'][0]['structuredData'];
    if (structuredData != null && structuredData['readableCodes'] != null) {
      var codes = structuredData['readableCodes'];
      for (var code in codes) {
        print("Type: ${code['type']}");
        print("Value: ${code['value']}");
      }
    }
  }
} catch (error) {
  // Handle error
  print("Scan failed: $error");
}
var configuration = {
  // Enable readable code extraction
  structuredData: ['readableCode'],

  // Specify which code types to detect
  structuredDataReadableCodeTypes: ['qr', 'ean13', 'code128', 'dataMatrix'],

  multiPage: false,
  skipPostProcessingScreen: true
};

// Start scan flow
cordova.plugins.GeniusScan.scanWithConfiguration(configuration,
  function(result) {
    // Access detected codes
    if (result.scans && result.scans[0].structuredData && result.scans[0].structuredData.readableCodes) {
      var codes = result.scans[0].structuredData.readableCodes;
      codes.forEach(function(code) {
        console.log("Type:", code.type);
        console.log("Value:", code.value);
      });
    }
  },
  function(error) {
    // Handle error
    console.error("Scan failed:", error);
  }
);

Supported Code Types

The SDK supports various barcode formats, including:

  • QR codes
  • EAN-13 and EAN-8
  • UPC-A and UPC-E
  • Code 128, Code 93, Code 39
  • Interleaved 2 of 5
  • Codabar
  • Data Matrix
  • PDF417
  • Aztec

Extracted Data

For each detected code, the SDK provides:

  • Type - The barcode format (QR, EAN13, etc.)
  • Value - The decoded data from the barcode

Products

Industries

Case Studies

Integration

Company

© 2025 The Grizzly Labs. All rights reserved.