Skip to content

How to extract a borderless table from a PDF into rows and columns

No lines on the page. No table in your output. Most PDF table extractors find a table by its ruling lines. A borderless table has none: it is just words placed in columns. Ask pdfplumber for tables on such a page with default settings and you get an empty list.

The fix is to find columns from the white space between words instead of from lines.

A tested function (pdfplumber)

import pdfplumber   # pip install pdfplumber

TEXT = {"vertical_strategy": "text", "horizontal_strategy": "text",
        "snap_tolerance": 3, "join_tolerance": 3, "intersection_tolerance": 3}

def borderless_table(pdf_path, page_number, box):
    """Rows of a table that has no ruling lines. box = (left, top, right, bottom) in PDF points."""
    with pdfplumber.open(pdf_path) as pdf:
        area = pdf.pages[page_number - 1].crop(box)
        rows = area.extract_table(TEXT) or []
    return [r for r in rows if any((c or "").strip() for c in r)]   # drop the blank rows between lines

borderless_table("report.pdf", 1, (60, 105, 500, 205))
# [['Region', 'Revenue', 'Growth'],
#  ['North America', '1,204.5', '4.1%'],
#  ['Europe', '980.0', '-1.2%'],
#  ['Asia Pacific', '', '12.7%'],
#  ['Latin America', '310.2', '0.4%']]

This is the real output on a five-row test table with three columns and one empty cell (pdfplumber, 3 Dec 2026). Two things in it matter:

  • Crop to the table first. Run the same settings on the whole page and the caption under the table becomes a row, split across columns ('Figures are unaudited. Growth is year over yea', 'r.', '' in our test). The text strategy treats every aligned word on the page as table content.
  • The empty cell stays empty. Asia Pacific has no revenue, and the row keeps three cells. A plain text dump would give Asia Pacific 12.7%, and your code would read 12.7% as revenue.

Camelot's stream flavor is built on the same idea (columns from white space, per its documentation; not tested here).

How to find the box

page.extract_words() gives each word with x0, top, x1, bottom. Take the header words of the table and the last row, and use their extremes plus a few points of margin. For a recurring report layout, find it once and keep it.

Where the white-space method breaks

Case What happens
A cell wraps onto two lines the second line becomes its own row with empty neighbours
Columns are close, or right-aligned numbers sit under a left-aligned header two columns merge, or one splits
The page is a scan there are no words to measure; you get nothing
Headers span several columns the span is assigned to one column, the rest come back empty

You can patch the first one (merge a row into the one above when its first cell is empty). The others need something that looks at the page the way a person does.

When to read the page with a vision model

A vision model sees the alignment, the wrapped cell and the spanning header as one picture, and it works on scans. ReadAnyDoc (open source, Apache-2.0) reads each table that way and returns it as HTML or Markdown, or as rows in your own schema with the page and box of every value:

import readanydoc   # pip install "readanydoc[engine]", needs a model key

result = readanydoc.parse("report.pdf")
for table in result.tables:
    print(table.content)        # HTML, with merged cells kept

Measured, both runs ours and public: on olmOCR-bench's table tests ReadAnyDoc scores 89.8 and Reducto 92.7; on RD-TableBench (1,000 tables) they are level, 88.84 and 88.85.

Where it loses to the function above: it takes 20 to 50 seconds a page and costs about $0.003 to $0.005 a page in model usage. pdfplumber is free and instant. If your tables are born-digital, single-line and well spaced, use pdfplumber.

Questions

Why does extract_tables() return an empty list? The default strategy looks for ruling lines. Check len(page.lines) and len(page.rects): if both are 0, the table is borderless and you need the text strategy.

Can I detect the table area automatically? On simple pages, yes: the table is the block of lines that share the same column positions. On mixed pages (paragraphs next to tables) a layout model or a vision model is more reliable than rules.

Does this work on scanned PDFs? No. A scan has no words to measure. Run OCR first, or read the page with a vision model.