Data Extraction
Docutain's Data Capture/ Data Extraction SDK for Xamarin can extract document data based on the detected text.
Initialization
Docutain's Xamarin SDK needs to be initialized prior to using any functionality of it as described here.
Set Analyze Configuration
If you do not need to analyze for BIC
and PaymentState
, you can skip this section and jump directly to Get the detected data.
If you want to analyze BIC
and / or PaymentState
, you need to set the analyze configuration accordingly prior to getting the data:
- Xamarin.Forms
- Xamarin.Android
- Xamarin.iOS
using Docutain.SDK.Xamarin.Forms;
var analyzeConfig = new AnalyzeConfiguration
{
ReadBIC = true, //defaults to false
ReadPaymentState = true //defaults to false
};
if (!DocumentDataReader.SetAnalyzeConfiguration(analyzeConfig))
{
var error = DocutainSDK.LastError;
}
using Docutain.SDK.Xamarin.Android;
var analyzeConfig = new AnalyzeConfiguration
{
ReadBIC = true, //defaults to false
ReadPaymentState = true //defaults to false
};
if (!DocumentDataReader.SetAnalyzeConfiguration(analyzeConfig))
{
var error = DocutainSDK.LastError;
}
using Docutain.SDK.Xamarin.iOS;
var analyzeConfig = new AnalyzeConfiguration
{
ReadBIC = true, //defaults to false
ReadPaymentState = true //defaults to false
};
if (!DocumentDataReader.SetAnalyzeConfiguration(analyzeConfig))
{
var error = DocutainSDK.LastError;
}
Get the detected data
In order to get the detected data of the scanned or imported document, call the following line of code:
- Xamarin.Forms
- Xamarin.Android
- Xamarin.iOS
using Docutain.SDK.Xamarin.Forms;
//...
//scan or import file
//...
var data = DocumentDataReader.Analyze();
using Docutain.SDK.Xamarin.Android;
//...
//scan or import file
//...
var data = DocumentDataReader.Analyze();
using Docutain.SDK.Xamarin.iOS;
//...
//scan or import file
//...
var data = DocumentDataReader.Analyze();
The detected data will be returned as JSON
string. Depending on how you configured your AnalyzeConfiguration
, the structure will be one of the two following. The differences will be in IBAN, Bank and PaymentState.
When reading BIC
is deactivated (default behaviour), you will get a value IBAN
which contains all detected IBANs:
{
"Address":
{
"Name1": "Verbandsgemeindeverwaltung Nastätten",
"Name2": "",
"Name3": "",
"Zipcode": "56352",
"City": "Nastätten",
"Street": "Postfach",
"Phone": "06772 802 0",
"CustomerId": "",
"IBAN": ["DE76570928000208303503", "DE41510500150710030316"]
},
"Date": "2020-01-24",
"Amount": "940.84",
"InvoiceId": "20/VA06894/0009500",
"Reference": "RNr:20/VA06894/0009500 vom 24.01.2020"
}
When reading BIC
is activated, you will get a value Bank
which contains tuples of the BIC
and the IBAN
, if any detected:
{
"Address":
{
"Name1": "Verbandsgemeindeverwaltung Nastätten",
"Name2": "",
"Name3": "",
"Zipcode": "56352",
"City": "Nastätten",
"Street": "Postfach",
"Phone": "06772 802 0",
"CustomerId": "",
"Bank": [{"BIC": "GENODE51DIE",
"IBAN": "DE76570928000208303503"},
{"BIC": "NASSDE55XXX",
"IBAN": "DE41510500150710030316"}]
},
"Date": "2020-01-24",
"Amount": "940.84",
"InvoiceId": "20/VA06894/0009500",
"Reference": "RNr:20/VA06894/0009500 vom 24.01.2020"
}
When reading the payment state is activated, you will get a value PaymentState
which contains either Paid
or ToBePaid
:
{
"Address":
{
"Name1": "Verbandsgemeindeverwaltung Nastätten",
"Name2": "",
"Name3": "",
"Zipcode": "56352",
"City": "Nastätten",
"Street": "Postfach",
"Phone": "06772 802 0",
"CustomerId": "",
"Bank": [{"BIC": "GENODE51DIE",
"IBAN": "DE76570928000208303503"},
{"BIC": "NASSDE55XXX",
"IBAN": "DE41510500150710030316"}]
},
"Date": "2020-01-24",
"Amount": "940.84",
"InvoiceId": "20/VA06894/0009500",
"Reference": "RNr:20/VA06894/0009500 vom 24.01.2020",
"PaymentState": "ToBePaid"
}