-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextResultPage.xaml.cs
52 lines (44 loc) · 1.68 KB
/
TextResultPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using Docutain.SDK.MAUI;
using System.Diagnostics;
namespace Docutain_SDK_Example_.NET_MAUI;
public partial class TextResultPage : ContentPage
{
public TextResultPage(FileResult fileResult)
{
InitializeComponent();
LoadData(fileResult);
}
private void LoadData(FileResult fileResult)
{
Task.Run(() =>
{
try
{
// If a FileResult is available, it means we have imported a file. If so, we need to load it into the SDK first.
if (fileResult != null)
{
// If a uri is available, it means we have imported a file. If so, we need to load it into the SDK first
if (!DocumentDataReader.LoadFile(fileResult.FullPath))
{
// An error occurred, get the latest error message
Debug.WriteLine($"DocumentDataReader.LoadFile failed, last error: {DocutainSDK.LastError}");
return;
}
}
// Get the text of all currently loaded pages.
// If you want text of just one specific page, define the page number.
// See https://docs.docutain.com/docs/Xamarin/textDetection for more details.
string text = DocumentDataReader.GetText();
MainThread.BeginInvokeOnMainThread(() =>
{
activityIndicator.IsRunning = false;
activityIndicator.IsVisible = false;
resultLabel.Text = text;
});
}
catch (Exception ex)
{
}
});
}
}