{
string docFileName = "c:\\MyData\\MyDocument.tiff";
var ocrOptions = new OCROptions(docFileName);
ocrOptions.OutputType = OCROutputType.Text;
// set a specific page if necessary
// (if not set, then all pages are scanned)
// ocrOptions.Page = pageIdx;
// set the resolution if necessary
// ocrOptions.Resolution = 400;
var output = await OCRManager.Instance.ExtractFromDocumentAsync(ocrOptions);
var textOutput = output as OCRTextOutput;
var text = textOutput.Text;
}
{
string docFileName = "c:\\MyData\\MyDocument.jpg";
var ocrOptions = new OCROptions(docFileName);
ocrOptions.OutputType = OCROutputType.Text;
// set a specific page if necessary
// (if not set, then all pages are scanned)
// ocrOptions.Page = pageIdx;
// set the resolution if necessary
// ocrOptions.Resolution = 400;
// set the language
// (de.traineddata should be installed at (arcgis_install_folder)\Resources\OCR)
// if file cannot be found an exception is thrown
ocrOptions.Model = "de";
try
{
var output = await OCRManager.Instance.ExtractFromDocumentAsync(ocrOptions);
var textOutput = output as OCRTextOutput;
var text = textOutput.Text;
}
catch (ArcGIS.Core.OCR.Exceptions.OCRException ex)
{
}
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)