The unique result identifier of the executed OCR process obtained by the GdPictureOCR.RunOCR method.
The 0-based index of the detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableCount(OCRResultID) - 1.
The 0-based index of the cell's column in a detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableColumnCount(OCRResultID) - 1.
The 0-based index of the cell's row in a detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableRowCount(OCRResultID) - 1.
Example





In This Topic
GdPicture14 Namespace / GdPictureOCR Class / GetTableCellText Method

GetTableCellText Method (GdPictureOCR)

In This Topic
Returns the text content of a cell in a specified table.
Syntax
'Declaration
 
Public Function GetTableCellText( _
   ByVal OCRResultID As String, _
   ByVal TableIdx As Integer, _
   ByVal ColummIdx As Integer, _
   ByVal RowIdx As Integer _
) As String
public string GetTableCellText( 
   string OCRResultID,
   int TableIdx,
   int ColummIdx,
   int RowIdx
)
public function GetTableCellText( 
    OCRResultID: String;
    TableIdx: Integer;
    ColummIdx: Integer;
    RowIdx: Integer
): String; 
public function GetTableCellText( 
   OCRResultID : String,
   TableIdx : int,
   ColummIdx : int,
   RowIdx : int
) : String;
public: string* GetTableCellText( 
   string* OCRResultID,
   int TableIdx,
   int ColummIdx,
   int RowIdx
) 
public:
String^ GetTableCellText( 
   String^ OCRResultID,
   int TableIdx,
   int ColummIdx,
   int RowIdx
) 

Parameters

OCRResultID
The unique result identifier of the executed OCR process obtained by the GdPictureOCR.RunOCR method.
TableIdx
The 0-based index of the detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableCount(OCRResultID) - 1.
ColummIdx
The 0-based index of the cell's column in a detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableColumnCount(OCRResultID) - 1.
RowIdx
The 0-based index of the cell's row in a detected table within the specified OCR result. It must be a value between 0 and GdPictureOCR.GetTableRowCount(OCRResultID) - 1.

Return Value

The text content of the cell.
Remarks

This method requires the KVP and Table Processing - Intelligent Redaction component to run.

Example
using GdPictureImaging img = new GdPictureImaging();
int invoiceId = img.CreateGdPictureImageFromHTTP("https://passportpdfapi.com/", "test/invoice.png", 443);
if (img.GetStat() != GdPictureStatus.OK)
{
    Console.WriteLine($"An error occurred during image loading ({img.GetStat()})");
    return;
}
 
using GdPictureOCR ocr = new GdPictureOCR();
ocr.ResourcesFolder = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "C:\\GdPicture.Net 14\\redist\\OCR" : "/mnt/c/GdPicture.Net 14/redist/OCR";
ocr.OCRMode = OCRMode.FavorAccuracy;
ocr.AddLanguage(OCRLanguage.French);
ocr.SetImage(invoiceId);
 
string ocrResultId = ocr.RunOCR();
 
if (ocr.GetStat() == GdPictureStatus.OK)
{
    Console.WriteLine();
    for (int tableIdx = 0; tableIdx < ocr.GetTableCount(ocrResultId); tableIdx++)
    {
        int colCount = ocr.GetTableColumnCount(ocrResultId, tableIdx);
        int rowCount = ocr.GetTableRowCount(ocrResultId, tableIdx);
        string[,] tableContent = new string[colCount, rowCount];
        int[] maxLinesInRows = new int[rowCount];
 
        for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
        {
            for (int colIdx = 0; colIdx < colCount; colIdx++)
            {
                tableContent[colIdx, rowIdx] = ocr.GetTableCellText(ocrResultId, tableIdx, colIdx, rowIdx);
            }
        }
 
        // Compute table formatting
        int[] widestCellInColumn = new int[colCount];
        for (int colIdx = 0; colIdx < colCount; colIdx++)
        for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
        {
            if (tableContent[colIdx, rowIdx].Length > widestCellInColumn[colIdx])
            {
                widestCellInColumn[colIdx] = tableContent[colIdx, rowIdx].Length;
            }
        }
        int rowLength = widestCellInColumn.Sum() + (3 * colCount);
        string separator = new string('=', (int)Math.Truncate((double)rowLength / 2) - 4);
 
        // Print table
        Console.WriteLine($"{separator} Table {tableIdx} {separator}");
        //if first two column is consired as header, consider the entire row as header
        bool isHorizontalHeaderRow = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, 0) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, 0);
        for (int rowIdx = 0; rowIdx < rowCount; rowIdx++)
        {
            bool isCurrentRowHeader = ocr.IsHeaderCell(ocrResultId, tableIdx, 0, rowIdx) && ocr.IsHeaderCell(ocrResultId, tableIdx, 1, rowIdx);
            for (int colIdx = 0; colIdx < colCount; colIdx++)
            {
                string prettifiedCell = tableContent[colIdx, rowIdx].Replace(Environment.NewLine, "").PadRight(widestCellInColumn[colIdx]);
                Console.Write($" {prettifiedCell} |{(!isHorizontalHeaderRow ? "|" : null)}");
            }
            Console.WriteLine();
            if (isCurrentRowHeader)
            {
                Console.WriteLine(new string('=', rowLength)); //If header row, write a header separator
            }
        }
        Console.WriteLine($"{separator} Table {tableIdx} {separator}");
        Console.WriteLine();
 
    }
    ocr.ReleaseOCRResult(ocrResultId);
    img.ReleaseGdPictureImage(invoiceId);
}
else
{
    Console.WriteLine($"OCR result : {ocr.GetStat()}");
}
See Also