Skip to main content

Document Scan

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



Initialize the Docutain Xamarin SDK as described here.



Declare the following permission in your AndroidManifest.xml.

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

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


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.


Start the Document Scanner

To start the Document Scanner you only have to call UI.ScanDocument and wait for it to return.

using Docutain.SDK.Xamarin.Forms;

var scanConfig = new DocumentScannerConfiguration();
var result = await UI.ScanDocument(scanConfig);
//user finished scan process, continue with your workflow
//generate PDF
var destinationPath = FileSystem.CacheDirectory + "/TestPDF.pdf";
var pdf = Document.WritePDF(destinationPath);
//get detected Text
var text = DocumentDataReader.GetText();
//get extracted data
var data = DocumentDataReader.Analyze();
//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 = new DocumentScannerConfiguration();

scanConfig.AllowCaptureModeSetting = true; // defaults to false
scanConfig.PageEditConfig.AllowPageFilter = false; // defaults to true
scanConfig.PageEditConfig.AllowPageRotation = false; // defaults to true

// Further customization options available ...

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:

Xamarin PDF Creation

Xamarin Text Detection

Xamarin Data Extraction