Aspose.OCR Table to Text for .NET

Aspose.OCR Table to Text for .NET extracts text from tables in individual raster images or batches of table images. The licensed plugin scope is focused on table detection, table recognition, and regular OCR over image input.

Installation and Setup

To get started, install the Aspose.OCR Table to Text package via NuGet or download the assembly from Aspose servers. See the Installation guide for detailed steps. Enable full functionality by configuring metered licensing as described in the Metered Licensing documentation.

Supported Plugin Options

The plugin license enables these API capabilities:

API areaSupported options
Licensed methodsRecognize, DetectTables, RecognizeTables
Input typeInputType.SingleImage
Area detection modesDetectAreasMode.TABLE, DetectAreasMode.LEAN
Preprocessing filtersPreprocessingFilter.AutoSkew(), Binarize(), Resize(), Dilate(), Invert(), Rotate(), Scale(), ToGrayscale(), Threshold(), Median()
Language selectionRecognitionSettings.Language supports 154 Language enum values, including Auto, Multilanguage, and Universal
Common public recognition settingsRecognizeSingleLine, UpscaleSmallFont, LinesFiltration, ThreadsCount, AutomaticColorInversion
Plugin license restrictionCustom RecognitionAreas are not included; keep RecognitionAreas empty

Skew correction is configured through PreprocessingFilter.AutoSkew(), not through RecognitionSettings. Manual rotation and other image cleanup steps can be configured with preprocessing filters such as Rotate(), Binarize(), ToGrayscale(), Threshold(), and Median(). Auto denoising, auto dewarping, contrast correction, and auto contrast are not listed for this plugin in the license service.

Supported Workflow

Use OcrInput with InputType.SingleImage. Add multiple table images with repeated input.Add(...) calls to recognize a batch in one request. For table extraction, set RecognitionSettings.DetectAreasMode to DetectAreasMode.TABLE, call Recognize, DetectTables, or RecognizeTables, and save the resulting OCR output in a format supported by the recognition result API.

Example: Extract Text from Scanned or Photographed Tables

Aspose.OCR.Metered metered = new Aspose.OCR.Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");

// Initialize recognition engine
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();

// Add images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("source1.png");
input.Add("source2.jpg");

// Configure recognition settings for tables
Aspose.OCR.RecognitionSettings recognitionSettings = new Aspose.OCR.RecognitionSettings();
recognitionSettings.DetectAreasMode = Aspose.OCR.DetectAreasMode.TABLE;

// Recognize table text
Aspose.OCR.OcrOutput results = recognitionEngine.Recognize(input, recognitionSettings);
foreach (Aspose.OCR.RecognitionResult result in results)
{
    Console.WriteLine(result.RecognitionText);
}

// Save results
results[0].Save("result.txt", Aspose.OCR.SaveFormat.Text);
results.Save("result.pdf", Aspose.OCR.SaveFormat.Pdf);
results.Save("result.xlsx", Aspose.OCR.SaveFormat.Xlsx);

Example: Detect Table Areas

Use DetectTables when you need to locate table regions before choosing the next processing step.

Aspose.OCR.Metered metered = new Aspose.OCR.Metered();
metered.SetMeteredKey("PublicKey", "PrivateKey");

// Initialize recognition engine
Aspose.OCR.AsposeOcr recognitionEngine = new Aspose.OCR.AsposeOcr();

// Add table images to OcrInput object
Aspose.OCR.OcrInput input = new Aspose.OCR.OcrInput(Aspose.OCR.InputType.SingleImage);
input.Add("table1.png");
input.Add("table2.jpg");

// Detect table regions
List<Aspose.OCR.RectangleOutput> tableAreas = recognitionEngine.DetectTables(input);
foreach (Aspose.OCR.RectangleOutput pageTables in tableAreas)
{
    Console.WriteLine($"Source: {pageTables.Source}, page: {pageTables.Page}");

    foreach (Aspose.OCR.Rectangle table in pageTables.Rectangles)
    {
        Console.WriteLine($"Table area: X={table.X}, Y={table.Y}, Width={table.Width}, Height={table.Height}");
    }
}

Output Formats and Saving Results

Use RecognitionResult.Save(...) to save a single recognized table image or page, OcrOutput.Save(...) to save the whole recognition batch, or AsposeOcr.SaveMultipageDocument(...) to combine several results into one output document.

Supported SaveFormat values are Text, Docx, Pdf, PdfNoImg, Xlsx, Xml, Json, HTML, EPUB, RTF, HOCR, Md, and Csv. For table-heavy content, Xlsx and Csv are useful for downstream spreadsheet or data-processing workflows.

Common Use Cases

  • Extracting structured data from financial reports.
  • Converting table images into recognized text.
  • Detecting table areas before downstream processing.

Tips and Best Practices

  • Use images with at least 300 DPI and good contrast for best results.
  • Pre-crop or deskew images to isolate table regions.
  • Use DetectAreasMode.TABLE for table-structured input and DetectAreasMode.LEAN for simple text layouts.
  • For low-quality table images, apply supported preprocessing filters such as PreprocessingFilter.AutoSkew(), Rotate(), Binarize(), Threshold(), ToGrayscale(), or Median() before recognition.
  • Set ThreadsCount to 1 on low-powered machines to reduce CPU pressure; increase ThreadsCount on multi-core systems to speed up batch processing.

By following these guidelines and leveraging its table recognition capabilities, Aspose.OCR Table to Text for .NET provides developers with a reliable solution for recognizing table text from image input.

 English