Skip to main content

Document Scan

The Docutain Document Scanner SDK for Flutter comes with integrated, ready to use UI components for the document scan process. Colors can be changed to match your branding.

ScanEditPreview

Initialization

Initialize the Docutain Flutter Scanner SDK as described here.

Camera Permission

Android

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.

iOS

You need to specify the reason for requesting access to the camera as part of the NSCameraUsageDescription in the Info.plist. If you don't the app will crash.

NSCameraUsageDescription

Start Scan

To start the scan process you only have to call DocutainSdkUi.scanDocument and wait for it to return.

var scanConfig = DocumentScannerConfiguration();
var result = await DocutainSdkUi.scanDocument(scanConfig);
if(result)
{
//user finished scan process, continue with your workflow
//generate PDF
File? pdfFile = await DocutainSdkDocument.writePDF(path, "testPDF");
//get detected Text
final text = await DocutainSdkDocumentDataReader.getText();
//get extracted data
final data = await DocutainSdkDocumentDataReader.analyze();
}
else
{
//user canceled scan process
}

An instance of DocumentScannerConfiguration is required to launch the document scanner. It provides the possibility to change some behaviours to adopt it to your needs.

var scanConfig = DocumentScannerConfiguration();

//currently supported configs
scanConfig.allowCaptureModeSetting = true; // defaults to false
scanConfig.pageEditConfig.allowPageFilter = true; //defaults to true
scanConfig.pageEditConfig.allowPageRotation = true; //defaults to true
scanConfig.autoCapture = true; //defaults to true
scanConfig.defaultScanFilter = ScanFilter.illustration; //defaults to ScanFilter.illustration
//For theming possibilities check [Theming]
scanConfig.colorConfig.colorPrimary = const Tuple2<Color, Color>(Colors.amber, Colors.red);
info

All parameters in DocumentScannerConfiguration are optional.

Result handling

After the scan process is successfully finished, you can do a bunch of things with the scanned pages:

Flutter PDF Creation

Flutter Image Export

Flutter Text Recognition

Flutter Data Extraction