Barcode Detection in Documents

Available on: iOS Android React Native Flutter Cordova Capacitor .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 barcode structured data type and specify which code types to detect.

let configuration = GSKScanFlowConfiguration()

// Enable barcode extraction
configuration.structuredData = [.barcode]

// Specify which code types to detect
configuration.structuredDataBarcodeTypes = [
    .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
    let codes = result.scans.first?.structuredData?.barcodes ?? []
    for code in codes {
        print("Type: \(code.type)")
        print("Value: \(code.value)")
    }
}, failure: { error in
    // Handle error
})

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

val configuration = ScanFlowConfiguration().apply {
    // Enable barcode extraction
    structuredData = EnumSet.of(ScanFlowConfiguration.StructuredData.BARCODE)

    // Specify which code types to detect
    structuredDataBarcodeTypes = EnumSet.of(
        Barcode.Type.QR,
        Barcode.Type.EAN13,
        Barcode.Type.Code128,
        Barcode.Type.DataMatrix
    )

    multiPage = false
    skipPostProcessingScreen = true
}

// Start scan flow
val scanLauncher = registerForActivityResult(ScanActivity.Contract()) { output ->
    when (output) {
        is FlowOutput.Success -> {
            // Access detected codes
            output.result.scans?.first()?.structuredDataResult?.barcodes?.forEach { code ->
                Log.d("Scanner", "Type: ${code.type}")
                Log.d("Scanner", "Value: ${code.value}")
            }
        }
        is FlowOutput.Error -> {
            // Handle error
        }
    }
}

scanLauncher.launch(configuration)

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

// Start scan flow
try {
  const result = await RNGeniusScan.scanWithConfiguration({
    // Enable barcode extraction
    structuredData: ['barcode'],

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

    multiPage: false,
    skipPostProcessingScreen: true
  });

  // Access detected codes
  if (result.scans && result.scans[0].structuredData?.barcodes) {
    const codes = result.scans[0].structuredData.barcodes;
    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 barcode extraction
  'structuredData': ['barcode'],

  // Specify which code types to detect
  'structuredDataBarcodeTypes': ['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['barcodes'] != null) {
      var codes = structuredData['barcodes'];
      for (var code in codes) {
        print("Type: ${code['type']}");
        print("Value: ${code['value']}");
      }
    }
  }
} catch (error) {
  // Handle error
  print("Scan failed: $error");
}
var configuration = {
  // Enable barcode extraction
  structuredData: ['barcode'],

  // Specify which code types to detect
  structuredDataBarcodeTypes: ['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.barcodes) {
      var codes = result.scans[0].structuredData.barcodes;
      codes.forEach(function(code) {
        console.log("Type:", code.type);
        console.log("Value:", code.value);
      });
    }
  },
  function(error) {
    // Handle error
    console.error("Scan failed:", error);
  }
);
import GeniusScan from '@thegrizzlylabs/capacitor-plugin-genius-scan';

// Start scan flow
try {
  const result = await GeniusScan.scanWithConfiguration({
    // Enable barcode extraction
    structuredData: ['barcode'],

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

    multiPage: false,
    skipPostProcessingScreen: true
  });

  // Access detected codes
  const codes = result.scans?.[0]?.structuredData?.barcodes;
  if (codes) {
    codes.forEach(code => {
      console.log("Type:", code.type);
      console.log("Value:", code.value);
    });
  }
} catch (error) {
  // Handle error
  console.error("Scan failed:", error);
}
using GeniusScanSDK.ScanFlow;
var scanFlowService = new ScanFlowService();

var configuration = new Dictionary<string, object>
{
    // Enable barcode extraction
    ["structuredData"] = new[] { "barcode" },
    // Specify which code types to detect
    ["structuredDataBarcodeTypes"] = new[] { "qr", "ean13", "code128", "dataMatrix" },
    ["multiPage"] = false,
    ["skipPostProcessingScreen"] = true
};
var result = await scanFlowService.ScanDocument(configuration);

// Access detected codes
var scans = (IList<object>)result["scans"];
var firstScan = (Dictionary<string, object>)scans[0];
if (firstScan.TryGetValue("structuredData", out var structuredDataObj))
{
    var structuredData = (Dictionary<string, object>)structuredDataObj;
    if (structuredData.TryGetValue("barcodes", out var barcodesObj))
    {
        var barcodes = (IList<object>)barcodesObj;
        foreach (var barcode in barcodes)
        {
            var code = (Dictionary<string, object>)barcode;
            Console.WriteLine($"Type: {code["type"]}");
            Console.WriteLine($"Value: {code["value"]}");
        }
    }
}

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

Ready to get started?

Start with a free trial license to test the SDK, or contact us directly for a custom quote tailored to your needs.

Products

Industries

Case Studies

Integration

Company

© 2026 The Grizzly Labs. All rights reserved.