DocsAPI LogoDocsAPI

OCR Layout Analysis: How Columns and Tables Break, Measured

Nupura UghadeNupura Ughade
/November 3, 2026/12 min read
In short

Layout analysis finds regions, reading order and table structure before characters are read. In our tests the same table image scored 0% or 100% depending on one segmentation setting, a two-column page came back with every word present and 88% of them misplaced, and a running-balance check flagged 85 of 91 statements with errors and none of 69 clean ones.

Layout analysis is the step where OCR decides what each piece of text is: a column, a heading, a table cell, a label or a value. Key-value extraction then links a label such as "Invoice date" to its value. Plain OCR gives you a stream of words. These two steps turn it into rows and fields a system can use, and in our tests they are where results swing hardest.

Three measured results, all from Tesseract 5.5.2 on pages with known answers. First, a two-column page came back with 100 percent of its words present and 88 percent of them in the wrong place, one setting away from a perfect read. Second, the same bank statement table scored 0 percent or 100 percent of rows correct depending on a single page segmentation setting, and which setting worked depended on whether the table had grid lines. Third, a running-balance check flagged 85 of the 91 statements that had an OCR error, with no false alarms on 69 clean ones. The rest of this guide shows how we got those numbers and what to do about them.

Context from our 1,700-document benchmark, which DocsAPI ran itself: three engines tied at 97 to 99 percent on clean typed English, then scored 64, 79 and 91 percent on multi-page bank statement tables. Recognizing characters was never the difference. Finding the structure was. These tests show why, on the free engine anyone can repeat.

How we tested

  • Two-column pages: 20 synthetic pages with two 3.3 inch columns of 10 point text, at 300 DPI. The correct reading order is left column first, then right.
  • Tables: 20 synthetic bank statements per condition, each with 28 rows of date, description, debit, credit and a running balance, so 560 rows per condition. Some had ruled grid lines and some had none.
  • Engine: Tesseract 5.5.2, English model, on a 10-core Apple M5 Mac. We did not run DocsAPI on these synthetic pages.
  • Page segmentation mode (PSM): Tesseract's setting for how to split a page into regions before reading. Mode 3 is automatic, 4 assumes a single column, 6 assumes a single block, and 11 reads sparse text with no structure.
  • Limits: one font, clean backgrounds, English. Real statements are messier, so use the pattern, not the exact percentages. We test every engine we evaluate on real files for that reason.

What does layout analysis do?

It splits a page image into regions and gives each a type and an order. A typical result lists a header block, a body in two columns, a table, a footer and a stamp, with coordinates for each. Three jobs matter most: region detection (where the text blocks and tables are), reading order (which block comes first), and region typing (table, paragraph, heading, or something to ignore such as a logo). A failure here is invisible to a character score, as the next test shows.

Reading order: every word right, the page unreadable

On the 20 two-column pages we ran four approaches and scored each against the correct left-then-right order.

ApproachWords wrong (in order)Words present (any order)
Automatic segmentation (mode 3)0.0%100%
Find the gap between columns, read each half (mode 6)0.0%100%
Single column mode (mode 4)88.2%100%
Single block mode (mode 6 on the whole page)88.2%100%

The last two rows are the trap. Told the page is one block, the engine read straight across both columns, interleaving a line from the left with a line from the right. Every word was recognized correctly, so a check that asks "did the words come out?" scores 100 percent, while a check of the order scores 12 percent. This is the failure that makes character-level accuracy a poor guide to whether a document is usable.

Automatic mode did fine on a clean two-column page. The second approach is worth knowing because it is simple and does not depend on the engine guessing: find the widest empty vertical band near the middle of the page, cut there, and read each half alone.

import numpy as np

def find_gutter(gray):
    ink = (gray < 160).sum(axis=0)      # dark pixels per pixel column
    w = gray.shape[1]
    lo, hi = int(w * 0.35), int(w * 0.65)
    best_len = best_start = run = start = 0
    for i, v in enumerate(ink[lo:hi]):
        if v == 0:
            if run == 0:
                start = i
            run += 1
            if run > best_len:
                best_len, best_start = run, start
        else:
            run = 0
    return lo + best_start + best_len // 2

cut = find_gutter(gray)
left, right = gray[:, :cut], gray[:, cut:]   # OCR each half separately

On real scans a few specks will cross the gap, so count a column as empty when it has a handful of dark pixels or fewer, not exactly zero.

Tables: the same image scored 0% or 100%

For tables we scored a row as correct only if one line of output held both the amount and the running balance, exactly right. That is the minimum for a row you can use. Here is the share of the 560 rows that passed, by segmentation mode and table style.

ModeNo grid linesRuled gridGrid erased first
3, automatic0%100%0%
4, single column100%100%not tested
6, single block100%0%100%
11, sparse text0%0%not tested

There is no gradual middle here. Each cell is all or nothing, and the winner changes with the table style. We looked at the output to see why:

  • Automatic mode on a borderless table read each column as its own block: all the dates, then all the descriptions. The values from one row ended up in different blocks, so no line held an amount and a balance together.
  • Sparse mode reads words with no line structure, so rows never form.
  • Single block mode on a ruled table turned the text into unreadable strings. The grid lines were read as characters, and the text around them came out as unreadable strings.
  • Erasing the grid first (we removed long horizontal and vertical lines with a morphological filter) fixed single block mode on the ruled table. It also broke automatic mode, which then scored 0 percent, the same as on a borderless table.

Single column mode was the one setting that passed both table styles in this test. That is a result about synthetic tables in one font, not a rule to copy, but the lesson carries: the segmentation choice is a layout decision, and a wrong one fails completely rather than partly. A pipeline that handles several table styles has to pick per region, not once for the whole job. That region-by-region choice is what a layout-aware engine does for you, and it is why tables separate engines by 64 to 91 percent in the benchmark while clean text does not.

Plain text loses the column

Even when the rows come out right, text output drops something a bank statement depends on: which column a number sat in. These are two real lines from our generated statements, as plain OCR returns them.

10 Feb GROCERY Fuel 11.99 6,821.27
07 Dec PHARMACY Subscription 68.59 6,741.31

The first is a debit and the second is a credit. In text they have the same shape, because the empty cell leaves no trace. Two things recover the direction. One is position: assign each amount to the nearest column header by its horizontal coordinate. On our clean borderless statements that got the direction right on 560 of 560 rows. The other is arithmetic, which is the next section. Either way you need the positions, not only the text, which is why structured output with coordinates matters for finance documents.

A running-balance check, measured

A bank statement checks itself. Each row's balance should differ from the previous balance by exactly that row's amount, in either direction. A misread digit or a mangled row breaks the chain at that point. This version ignores whether the row was a debit or a credit, because we just showed that text alone cannot tell.

def check_running_balance(rows, expected_rows, tolerance=0.005):
    """rows: (amount, balance) per parsed row, in page order."""
    flagged = []
    if len(rows) != expected_rows:
        flagged.append("row count %d, expected %d" % (len(rows), expected_rows))
    for i in range(1, len(rows)):
        amount, balance = rows[i]
        previous = rows[i - 1][1]
        if abs(abs(balance - previous) - amount) > tolerance:
            flagged.append(i)
    return flagged

We ran it on all 20 statements in each condition, reading with single column mode, and counted statements that had at least one error against statements the check flagged. A statement counts as having an error if any row was wrong, lost, or could not be matched to its source row.

Condition (no grid lines)Rows exactly rightStatements with an errorFlagged by the checkClean statements falsely flagged
Clean, 300 DPI100%0 of 20none needed0 of 20
150 DPI98.0%7 of 207 of 70 of 13
Tilted 2 degrees, 200 DPI, blur, noise, JPEG quality 4069.1%20 of 2014 of 20none clean
Same, straightened first93.0%17 of 2017 of 170 of 3

Read the table in three steps.

  1. The check is trustworthy when it speaks. Across the 69 statements with no errors, borderless and ruled together, it raised zero false alarms. Everything it flagged was worth a look.
  2. It found nearly every error it had rows to test. At 150 DPI it caught 7 of 7. After straightening, 17 of 17. Counting the ruled runs too, it flagged 85 of the 91 statements that had an error.
  3. Its misses are the part to design for. In the roughest condition it flagged 14 of 20. We looked at the six it did not flag. In four, OCR returned no rows at all, and an arithmetic check over zero rows has nothing to fail. In the other two, every number passed and only a description on the last row was garbled, which arithmetic cannot see. The fix for the first kind is the row count in the code above, plus checking the first and last balance against the statement's printed opening and closing figures.

The bigger number is in the third row against the fourth. Straightening the page before reading took rows exactly right from 69 percent to 93 percent, with no change to the engine. The method and the thresholds are in how OCR works, and the same idea applies to invoices, where line items should add up to the subtotal and the subtotal plus tax should equal the total. Reconciling balances across several accounts is a separate problem, covered in multi-account bank statement OCR. A chain that does not add up can also point to an edited statement, which bank statement fraud detection looks at.

Grid lines made it worse, even with the best mode

One more pattern from the same table. With the single column mode that worked on both styles, the ruled tables still did worse than the borderless ones once the page was degraded: 54.6 percent of rows exactly right against 69.1 percent for the same page without lines, and 69.8 percent against 93.0 percent after straightening. The check still flagged 20 of 20 ruled statements in both cases, so the errors were caught, but there were more of them. If you control the document format, a statement without cell borders reads better. If you do not, test ruled and borderless samples separately, because they fail differently.

How does OCR read a table?

It finds the table region, finds the rows and columns, assigns each word to a cell, handles cells that span several rows or columns, and outputs rows and columns instead of lines of text. Tables break in a few predictable ways:

Table problemWhat goes wrong
No ruling linesColumns must be inferred from spacing, and values drift into the neighboring column
Ruling linesLines are read as characters or break the layout, as in our single block result
A table that continues over several pagesEach page is read alone, so headers go missing and rows are not joined
Wrapped text in a cellOne long description becomes two rows
Merged or spanning cellsA total or a group heading lands in one column only
Numbers with signs and bracketsA minus sign or a bracket is dropped or moved

On invoices, where line items are the table, the benchmark gave 81 percent for Docling, 87 for LlamaParse and 93 for DocsAPI. We cover that case in invoice line item OCR.

Joining a table that continues across pages

A long statement repeats its header on some pages and splits a table at the page break. Processed page by page, a later page starts with no header, and a row can be cut in half. Three rules help. Treat a table on page N as a continuation of page N minus 1 if the column positions match and the first rows are not headers. Drop repeated header rows when merging. And run the balance check across the join: a row lost or duplicated at the break shows up as a flag on the row after it. We did not measure this case separately, so test it on your own multi-page files.

What is key-value extraction?

It pulls out a labeled field and its value from a page, such as "Total due" and "1,240.00". There are two broad ways to do it:

  • Template or rule based: you say where a field sits or what text surrounds it. It works well for one fixed form and fails when a vendor changes its layout.
  • Learned or model based: a model reads the page and finds the field by meaning and position. It copes with layouts it has not seen, with less predictable mistakes. We compare the two for invoices in rules-based vs AI invoice extraction.

The hard cases are where the label and value are not adjacent: a label above its value, a value two columns to the right, a label that appears twice (a "Date" for the invoice and a "Date" for shipping), or a field with no label, like a vendor name that is only a logo. Without a template, a system usually combines three signals: the words near the value, the position of the value on the page, and its appearance, such as bold type or a box. Any one alone is easy to fool, which is also why such systems can fail in ways a fixed template never would, for example by picking the subtotal when the page also shows a grand total.

Confidence per field, not per page

A single score for a page hides problems. What you want is one score per field or table cell, so a person reviews only the cell that is uncertain. A statement with 300 values and 3 low-confidence cells should send 3 items to review. How reliable those scores are is a separate question, and our calibration test shows a sizable share of errors can still carry a high score, which is the reason to pair confidence with arithmetic checks like the one above.

Forms add two non-text elements. A checkbox should come back as marked or empty, and a signature as present or missing. Detecting that a signature exists is a different job from verifying who signed, and OCR does not do the second. Check how any tool handles both before you rely on it.

Questions to ask a vendor, based on what failed

  • Does it read ruled and borderless tables equally well? Send both.
  • Does it rebuild tables that continue over several pages, with headers dropped from page two?
  • Does the output keep coordinates, so a debit can be told from a credit?
  • Is there a confidence score per cell and per field?
  • What does the response look like when a page produces no rows? A silent empty result is how four of our twenty worst statements slipped past a check.
  • Can I test it on my own worst multi-page documents before I decide?

None of these is about character accuracy. On clean text every serious engine is close, and the questions that separate vendors are about structure.

A field-level test sheet

Document-level accuracy hides structure errors, so test per field. Pick 30 real documents, list the fields that matter, and fill in a sheet like this for each tool:

FieldTimes presentFoundValue correctWrong cell or label
Invoice number30
Invoice date30
Total due30
Line item amountscount them
Table rows on page 2 and latercount them

The last column matters most. A value that was found but landed under the wrong label is worse than one that was missed, because it looks right. For how to turn the sheet into a pass mark, see how to measure OCR accuracy.

Choosing a tool by structure, not by headline accuracy

DocsAPI extracts fields and tables, flags low-confidence fields for review, and includes table extraction and classification in its price of $0.02 per page and up. The benchmark was run by DocsAPI, so cite it as DocsAPI's own and verify it on your documents. If your volume is large, bulk OCR processing covers speed, cost and review time, and data normalization for extracted documents covers cleaning the values once they are out.

Common questions

Frequently asked questions

The step that splits a page into regions such as headings, paragraphs, columns and tables, gives each a type, and works out the reading order, before any characters are recognized. A failure here can leave every word correct and the page unusable.

Finding a labeled field and its value in a document, for example the label Invoice date and the value 14 March. It turns a page of text into named fields a system can use.

If the engine is told to read the page as one block, it reads straight across both columns. In our test every word was still recognized, but 88.2 percent were out of order. Automatic segmentation, or cutting the page at the gap between columns and reading each half, gave 0.0 percent wrong.

Tables combine hard cases: missing or heavy grid lines, wrapped cells, merged cells and page breaks. In our test the same table image scored 0 percent or 100 percent of rows correct depending on one segmentation setting, and the working setting changed with the table style.

Use the running balance: each row's balance should differ from the previous one by exactly that row's amount. In our tests this check raised no false alarms on 69 clean statements, and flagged 85 of 91 statements that had an error. Add a row count and check the opening and closing balances, because a page that returns no rows passes silently.

Plain text output drops the empty cell, so a debit and a credit line look identical. Assign each amount to the nearest column header by its horizontal position, which was right on 560 of 560 clean rows in our test, or use the balance arithmetic to infer direction.

Templates are predictable and work for one fixed form but fail when the layout changes. Model-based extraction handles layouts it has not seen but can make less predictable mistakes. Many teams test both on their own documents.

In our own 2026 benchmark, DocsAPI scored 91 percent on multi-page bank statement tables and 93 percent on invoice line items, ahead of the other engines compared. The benchmark was run by DocsAPI, so cite it as DocsAPI's own and test on your documents.

Nupura Ughade

Content Marketing Lead, DocsAPI

Nupura Ughade creates clear, insightful content on OCR, document AI, and fintech. She combines technical depth with real-world finance use cases to help engineers and operations leaders navigate digital transformation with confidence.

Want to see it on your own documents?

Try our free OCR tool in your browser, or book a demo to see how DocsAPI reads the document types covered in this guide.