ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Core.OCR Namespace / OCROutputType Enumeration
Example Example

In This Topic
    OCROutputType Enumeration
    In This Topic
    The output type for the OCR operation. See OCROptions.OutputType and OCRManager.ExtractFromDocumentAsync for usage.
    Syntax
    Members
    MemberDescription
    Text Extracts information from the document image as text.
    TSV Extracts information from the document image as Tab Separated Values (TSV). This provides detailed layout information at multiple levels - blocks, paragraphs, lines, words; each accompanied by bounding box coordinates.
    Example
    Extract text from a document using OCROptions
    {
      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;
    }
    Extract text from a document using a different model
    {
      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)
      {
      }
    }
    Extract TSV output from a document
    {
      string docFileName = "c:\\MyData\\MyDocument.bmp";
    
      var ocrOptions = new OCROptions(docFileName);
      ocrOptions.OutputType = OCROutputType.TSV;
    
      // 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);
      if (output is OCRTSVOutput ocr_tsvOutput)
      {
        // process the tsv output
        foreach (var page in ocr_tsvOutput.Pages)
        {
          foreach (var block in page.Blocks)
          {
            foreach (var para in block.Paragraphs)
            {
              foreach (var line in para.Lines)
              {
                foreach (var word in line.Words)
                {
                  var content = word.Content;
                  var confidence = word.Confidence;
    
                  // process content according to confidence
                }
              }
            }
          }
        }
      }
    }
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Core.OCR.OCROutputType

    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.8 or higher.
    See Also