Skip to main content

Barcode Scan

The Docutain SDK comes with integrated, ready to use UI components for the barcode scan process.

BarcodeUI


Supported Barcode Formats

  • code128
  • code39
  • code93
  • codabar
  • ean13
  • ean8
  • itf
  • upca
  • upce
  • qr
  • pdf417
  • aztec
  • datamatrix

Initialize

Initialize the Docutain SDK as described here.

Camera Permission

Declare the following permission in your AndroidManifest.xml

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera"/>
info

Runtime permission for camera is handled automatically by the Docutain SDK.

Start the barcode scanner

To start the barcode scan process you only have to call scanBarcode with valid barcodeScannerConfiguration and wait for it to return.

        const scanConfig = {
codeFormats: ['CODE_128', 'CODE_39', 'CODE_93', 'EAN_13', 'EAN_8', 'ITF', 'UPC_A', 'UPC_E', 'CODABAR'],
};
try
{
result = await DocutainSDKBarcode.scanBarcode(scanConfig);
}
catch(ex)
{
errorMsg('scanBarcode', ex);
return
}

Valid BarcodeScannerConfiguration is required to launch the barcode scanner. It provides the possibility to change some behaviours to adopt it to your needs.


const scanConfig = {
vibrateOnSuccess: false, //defaults to true
beepOnSuccess: true, //defaults to false
codeFormats: ['CODE_39'], //defaults to all supported barcode formats
//more configs available
tip

If you need to scan only specific barcode formats, you can improve the barcode scan performance by defining the barcode formats by setting scanConfig.codeFormats like in the example above.

info

All parameters in BarcodeScannerConfiguration are optional.