ReadAsync issue
A41056 opened this issue · 0 comments
A41056 commented
`string _zPdfFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "File", "hdcc.pdf");
var _IronOcr = new IronTesseract();
_IronOcr.Language = OcrLanguage.Vietnamese;
using (var _Input = new OcrInput())
{
_Input.AddPdfPages(_zPdfFilePath, null, null, null);
string _zPath = "hdcc-searchable.pdf";
var _t1 = _IronOcr.ReadAsync(_Input, null);
var _t2 = initializeWebViewAsync();
Task.WhenAll(_t1, _t2).ContinueWith((_t) =>
{
if (Disposing || IsDisposed)
return;
if (_t1.IsCanceled || _t2.IsCanceled)
return;
else if (_t1.Exception != null)
MessageBox.Show(_t1.Exception.InnerException.Message);
else if (_t2.Exception != null)
MessageBox.Show(_t2.Exception.InnerException.Message);
else
{
if (InvokeRequired)
{
Invoke((MethodInvoker)(() =>
{
_t1.Result.SaveAsSearchablePdf(_zPath);
string _zUrl = "file:///" + Path.GetFullPath(_zPath).Replace('\\', '/');
if (webView != null && webView.CoreWebView2 != null)
{
webView.CoreWebView2.Navigate(_zUrl);
}
}));
}
else
{
_t1.Result.SaveAsSearchablePdf(_zPath);
string _zUrl = "file:///" + Path.GetFullPath(_zPath).Replace('\\', '/');
if (webView != null && webView.CoreWebView2 != null)
{
webView.CoreWebView2.Navigate(_zUrl);
}
}
}
});
}`
I want to convert from an image, scanned pdf file to a searchable pdf. It works fine with Read(), but the main thread will be blocked until the process is finished. So I'm using ReadAsync() to not block the main thread, but I have the error "Recognition of image failed". I don't know why, because the Read() run fine so it can't be an image quality problem. Please help me.