Detecting Dotted Border Tables with ReadDocumentAdvanced
ReadDocumentAdvanced extracts table data cell by cell, but it cannot detect tables whose borders are dotted or dashed (for example, border: 1px dotted black). The text on the page may still be readable, yet accessing the table object fails because the engine never recognizes the table.
When you call ReadDocumentAdvanced on a document with a dotted-border table and then read its cells, it throws:
Unhandled exception. System.InvalidOperationException: Sequence contains no elements
The gaps between the dots break the border into discontinuous segments, so the OCR engine sees no continuous contour to treat as a table boundary. With no Tables detected, Tables.First() has nothing to return.
Solution
Apply the Dilate() filter before processing. Dilation expands the dark pixels in the image, closing the gaps between dots so the border reads as one solid line. The engine can then detect the table object and return its cells.
1. Enable table reading and load the input
Turn on ReadDataTables so the engine builds structured table output, then load your image.
var ocr = new IronTesseract();
ocr.Configuration.ReadDataTables = true;
var input = new OcrInput();
input.Load("image-20250408-144240.png");
var ocr = new IronTesseract();
ocr.Configuration.ReadDataTables = true;
var input = new OcrInput();
input.Load("image-20250408-144240.png");
Imports IronTesseract
Dim ocr As New IronTesseract()
ocr.Configuration.ReadDataTables = True
Dim input As New OcrInput()
input.Load("image-20250408-144240.png")

2. Dilate before reading
Call Dilate() on the input to merge the dotted border into a continuous contour, then run ReadDocumentAdvanced.
input.Dilate();
input.SaveAsImages("export.png", AnyBitmap.ImageFormat.Png);
var res = ocr.ReadDocumentAdvanced(input);
Console.WriteLine(res.Tables.First().CellInfos.First().CellText);
input.Dilate();
input.SaveAsImages("export.png", AnyBitmap.ImageFormat.Png);
var res = ocr.ReadDocumentAdvanced(input);
Console.WriteLine(res.Tables.First().CellInfos.First().CellText);
Dim res = ocr.ReadDocumentAdvanced(input)
input.Dilate()
input.SaveAsImages("export.png", AnyBitmap.ImageFormat.Png)
Console.WriteLine(res.Tables.First().CellInfos.First().CellText)
Dilate() converts the visual dotted lines into solid borders the engine can trace, so res.Tables is now populated and the cell text reads cleanly. The SaveAsImages call is optional; it lets you inspect the dilated image to confirm the borders closed as expected.


