How to extract tables from PDF files, scans and images

For finance and operations teams that pull line items and transactions out of PDFs, and for the developers who build that step. Pick a method by file type and volume, then check the rows it returns.

Illustration of an invoice line-item table extracted from a PDF into a structured table

Key takeaways

  • To extract tables from PDF files, match the method to the file. Excel and free Python libraries read PDFs made by software, which store their own text. Scans and photos first need OCR (optical character recognition) to read the characters.
  • Table extraction happens in two stages. Table detection finds where the table is, and table structure recognition works out which row and column each value belongs to.
  • The hard cases are merged cells, borderless layouts, tables that span pages, poor scans and a different layout from every sender.
  • Tables that run across pages have to be joined into one. Excel's PDF import joins similar tables on consecutive pages by default. Most Python libraries leave that step to your code, but Camelot 2.0 can join them with one call.
  • Extraction isn't finished until the table is validated. Rows should add up to the total, balances should reconcile, and uncertain cells should go to a person.
On this page
  1. How to extract tables from a PDF
  2. What is table extraction?
  3. Why tables are hard to extract
  4. How table extraction works
  5. Table extraction techniques
  6. How to join a table that runs across pages
  7. How to extract a table from an image or a scan
  8. Python libraries and OCR APIs for PDF tables
  9. How to validate extracted table data
  10. How to choose table extraction software
  11. How Docsumo extracts tables
  12. How many cells did your reviewers have to fix?
  13. Frequently asked questions

To extract tables from PDF files, use a tool that finds each table and rebuilds its rows and columns. Excel and free Python libraries read PDFs made by software, but scans and photos first need OCR to read the characters. Tables that arrive every day from many senders also need checks and a person to review uncertain cells.

How to extract tables from a PDF

Start with the file, because it decides whether you need OCR. Try to select a word in the PDF. If you can, the file has a text layer. That's the text the software stored when it made the PDF. If you can't, the page is a picture.

  • Native PDFs

    Made by software, with a text layer, so tools read the characters and their positions directly.
  • Scanned PDFs

    A picture of a page with no text layer. OCR reads the characters first, and its errors carry into the table.
  • Images and photos

    Screenshots, phone photos and faxes. They work like scans, but they also have tilted pages, shadows and uneven light to fix.

Then pick the method that fits how many tables you have and who will run it.

Your situationMethodWhat it readsTables across pages
Tables arrive every day from many sendersA document AI platform such as Docsumo (our product)Any document type, scans and handwritten text includedJoined into one table, with the headers mapped
Scans and photos, in your own codeA cloud OCR API such as Amazon Textract, Azure Document Intelligence or Google Document AIScans, photos and PDFsAzure's docs say to join the pages into one table after Azure reads them
PDFs with a text layer, in your own codeA Python library such as Camelot, pdfplumber or PyMuPDFPDFs with a text layer; Camelot reads scans only with its ML and OCR add-onsCamelot 2.0 joins them with stack_contiguous(); with the others, your code does
A few tables, no codeExcel for Microsoft 365 on Windows, Data > Get Data > From File > From PDFPDFs with a text layer; Microsoft's docs describe no OCR step for scansSimilar tables on consecutive pages are joined by default
A few tables, some of them scannedAdobe Acrobat, exporting to ExcelPDFs with a text layer, and scans with text recognition turned onYou choose a worksheet per table, per page or for the whole document

Tabula is a free desktop app for the same job. You draw a box around each table and export it as CSV or Excel. It reads PDFs with a text layer only, and its last release came out in June 2018.

What is table extraction?

Invoices, bank statements, rent rolls and claim forms keep their most useful data in tables. That means line items and transactions, or units and charges. A PDF only stores instructions such as "put this text here, draw this line there". The file does not record which text belongs to which row or cell. Table extraction works out the rows and columns again. The table data inside the PDF then comes out as rows and columns, with each value in the right cell.

An invoice table detected on the page (table detection), split into rows and columns (table structure recognition), and output as a clean table of description, price, quantity and amount (table extraction)

Table detection finds where each table sits on the page. Table structure recognition then finds the rows and cells inside it, including headers and merged cells. On a scan or a photo, OCR has to read the characters before either step can start.

Why tables are hard to extract

Five things make simple extraction tools fail.

  • Merged cells and nested headers

    A header that covers several smaller columns, or a small table inside one cell, makes simple tools put values in the wrong column.
  • Tables that span pages

    Tools that read one page at a time don't link the rows on page 2 to the header on page 1.
  • Borderless layouts

    The table has spaces instead of lines between cells, so columns that sit close together get merged.
  • Scan quality

    Blur, tilted or rotated pages and low resolution make OCR misread characters. Every later step then works with those mistakes.
  • A different layout from every sender

    One vendor's invoice has 5 columns and the next has 8. Templates made for one layout stop working as you add senders.

How table extraction works

Whatever the method, the pipeline is the same. Get the text, find the table, rebuild its grid, then clean and check the result.

  • Native PDFs
  • Scanned PDFs
  • Images and photos
Table AI
  1. 01OCR if needed
  2. 02Detect the table
  3. 03Recognize rows and columns
  4. 04Map headers and clean rows
  5. 05Validate
CSV, Excel, JSON or your system
From a page to a usable table

Tools differ most in the last two steps, cleaning and validation. Cleaning means removing subtotals and repeated headers, joining tables that continue across pages, and matching each column to a field in your system. Validation means checking that the numbers add up.

Table extraction techniques

There are four main ways to extract tables. Each newer method was built to fix the limits of the one before.

  • Rules and templates

    Ruling lines, spacing and header words such as Qty and Amount mark out the table; every new layout needs new rules.
  • Machine learning

    A program learns which parts of a page are tables. It uses signals an engineer chooses, such as lines, how closely text is packed and whether text lines up in columns.
  • Deep learning

    The model learns the signals that mark a table from many examples, so no engineer has to choose them. CascadeTabNet (2020) finds tables and their cells in one model. Microsoft's Table Transformer learned from nearly one million tables taken from scientific articles.
  • LLMs and vision-language models

    Large language models (LLMs) read text, and vision-language models read images and text together. Both read the whole table with the words around it, so they can fill in a missing header. They cost more and can return values that aren't on the page.
CriteriaRule-basedMachine learningDeep learningLLM and vision
Training dataNoneLabeled examplesLarge labeled setsNone to start; examples help
New layoutsNew rules each timeModerateGood, if trained on similar documentsGood
Main riskBreaks on layout changesFeature upkeepWeak on unfamiliar document typesValues that aren't on the page
Cost to runVery lowLowModerateHighest

In daily use, teams often combine these methods. The software gives each value a confidence score. That score and your validation rules decide which cells a person reviews.

How to join a table that runs across pages

A long table doesn't fit on one page. A bank statement's transactions, a rent roll or a loss run can fill several pages. A tool that reads one page at a time returns one table per page. The rows on page 2 then sit apart from the header on page 1.

Joining them takes three steps. First, spot the continuation, which may be the same columns, a repeated header or a row cut off at the page break. Next, carry the header forward and drop the header rows that repeat on each page. Last, count the rows. Extra rows mean repeated headers were kept, and missing rows mean a page wasn't joined.

Excel's PDF import joins similar tables on consecutive pages by default. In code, Camelot 2.0 can do the joining for you. Its stack_contiguous() call joins tables that continue across pages when they have the same number of columns. A first-row option also drops the header that repeats on each page.

With the other Python libraries, your own code does the joining. Azure's OCR API leaves this step to you as well. Its docs say to join the pages into one table after Azure has read them. Docsumo joins a table that runs across pages into one table and maps its headers. A long statement then comes out as one list of transactions.

How to extract a table from an image or a scan

A photo or screenshot has no text layer, so OCR comes first. Pick the route that fits how often you do it.

  1. One table, nowExcel's Data > From Picture turns an image or a screenshot into cells and asks you to review them before inserting. That's where to catch misreads.
  2. A script you controlThe Python library img2table finds tables in images and PDFs, borderless ones included, with an OCR engine such as Tesseract, PaddleOCR or EasyOCR.
  3. Many images, every dayA document AI platform straightens tilted pages, reads the table, scores each cell and sends the uncertain ones to a person.

Whatever the route, straighten the image, crop to the table and use the highest resolution you have. For a scanned PDF, Acrobat's export to Excel can read the page once its text recognition setting is on.

Python libraries and OCR APIs for PDF tables

Free Python libraries read the text layer well. Each one returns the tables page by page. Camelot 2.0 can join tables that run across pages, while the others leave that to your code. With every library, your code maps the headers and checks the totals.

LibraryBest forScanned PDFs
CamelotRuled tables (lattice) and whitespace-separated tables (stream) in native PDFs, with an accuracy score for each table; since version 2.0, stack_contiguous() joins tables across pagesOnly with its optional ML and OCR add-ons
tabula-pySimple, well-structured tables; a Python wrapper for tabula-java (needs Java)No
pdfplumberDetailed access to characters, lines and tables through find_tables and extract_tablesNo; it has no OCR
PyMuPDFPage.find_tables(), with line- and text-based strategies and export to pandasNot on its own
img2tableTables in images and PDFs, including borderless tablesYes, with an OCR engine you choose

Cloud OCR APIs read scans and photos as well. Amazon Textract returns each table as cells with a row and column number. It also marks merged cells and column headers, and it finds table titles and footers. Azure Document Intelligence marks column headers and reads rotated tables. Google's Form Parser handles only simple tables, where no cell spans two or more rows or columns. Each API's docs describe the table structure it returns. You build the checks on the numbers yourself, such as totals that add up.

If you send the tables to a large language model (LLM), export them as Markdown, a plain-text format. Camelot and PyMuPDF can both do that. For a worked pdfplumber example, see how to extract data from PDF.

How to validate extracted table data

Pulling the table out is only half the work. Checking it is what makes the data safe to use. A bank statement shows how the checks work. Harbor Street Bakery's July statement from First Midwest Bank has a transactions table of 142 rows. Each row has a date, a description, an amount and a running balance.

The first row is a Square deposit of 4,812.30 on July 2. It takes the balance from 42,180.55 to 46,992.85. A check repeats that sum on every row. If an amount was misread, the check fails on that row. At the end, the 42,180.55 opening balance plus 88,412.10 in deposits, minus 91,686.44 in withdrawals, has to equal the 38,906.21 closing balance.

Account
FieldExtracted valueConfidence
Account holderHarbor Street Bakery LLC
Address118 Harbor St, Portland, ME
Bank nameFirst Midwest Bank
Account number•••• 4821
Account typeBusiness checking
Statement period2026-07-01 → 2026-07-31
A bank statement's transactions table, read row by row. Each row keeps its date, description, amount and running balance, so every row can be checked.
  • Rows add up to the totalLine items that add up to 10,050 don't match an extracted total of 10,500. The record goes to review before it reaches your ERP or accounting system.
  • Balances reconcileOn a bank statement, the opening balance plus credits minus debits equals the closing balance.
  • Documents agreeInvoice lines match the purchase order; rent roll totals match the operating statement.
  • Every page is therePage counts and running totals confirm that a multi-page table isn't missing rows.
  • Uncertain cells go to a personHigh-confidence rows go through; the rest go to review.

How to choose table extraction software

The methods table at the top gives you a shortlist. Before you commit, test each tool on your own files.

  1. Use your worst filesMerged headers, borderless tables, tables across three or more pages, rotated pages and poor scans. Clean samples make every tool look good.
  2. Score cells, not documentsCount right values and missed cells. A tool can find every table and still drop rows.
  3. Score the structureA right value in the wrong column is still wrong. The TEDS score compares the extracted table's structure and content with the original.
  4. Count rows on long tablesExtra rows mean repeated headers were kept; missing rows mean a page wasn't joined.
  5. Count the fixesHow many cells a person had to correct is the number that matters in production. More in how to measure OCR accuracy.

What we'd do. Don't rely on the accuracy figure on any vendor's page, ours included. Run each tool on the same set of your own worst files. Then count how many cells a person had to fix. That count reflects your own layouts, scan quality and multi-page tables, which no published number can.

How Docsumo extracts tables

Docsumo's Document AI reads the tables in documents such as invoices, bank statements and the rent rolls used in CRE underwriting. It reads any document type, including scans and handwritten text. Tables that run across pages are joined into one table, with the headers mapped. On bank statements, it checks each transaction against the statement's running balance.

Values the model is unsure about go to a reviewer, who can click each one to see its source line on the page. The rows reach your systems through the API and webhooks or an Excel export. Docsumo's Data Table also gathers the data from every document of one type into one table, which you can export to CSV or Google Sheets. Docsumo is built for large volumes of business documents. For a single table from a research paper, a free library or Excel is enough.

  • 99%field-level accuracy across 250+ document types
  • 95%+of documents processed straight through, without manual review

How many cells did your reviewers have to fix?

If reviewers correct a few cells a week, the tool reads your tables and the checks catch the rest. If they retype whole rows, the tool isn't splitting your tables into the right rows and columns. Look at those tables for merged cells, page breaks and new sender layouts. Those are the files to bring to a demo or a trial.

Book a demo with a few of your own documents, or start a free trial.

Frequently asked questions

What is table extraction?

Table extraction finds the tables in a PDF, scan or image. It turns them into structured rows and columns for a spreadsheet, database or business system. OCR alone returns the characters. Table extraction also works out which row and column each value belongs to.

How do I extract a table from a PDF?

If the PDF has a text layer, Excel's PDF import or a Python library such as Camelot or pdfplumber can pull the table out. A scanned PDF needs OCR first. If you get many PDFs from many senders, use a document AI platform. It connects to your systems through an API and sends unsure values to a person to review.

How do I extract a table from a PDF into Excel?

In Excel for Microsoft 365 on Windows, choose Data > Get Data > From File > From PDF, then pick the table and load it. Similar tables on consecutive pages are joined by default. Adobe Acrobat's export to Excel can put each table on its own worksheet, and its text recognition setting reads scanned pages.

How do I extract a table from an image or a scanned PDF?

Run OCR first, because an image has no text layer. For a single image, use Excel's Data from Picture. In code, the img2table library finds the table and uses an OCR engine to read it. Poor scans cause misreads, so send the cells the software is unsure about to a person.

Which Python library is best for extracting tables from PDFs?

For PDFs with a text layer, Camelot suits ruled tables and scores each table it finds. Since version 2.0, it can also join tables that run across pages. pdfplumber gives detailed access to each character and line. For scans and images, img2table pairs table detection with an OCR engine you choose.

What is a data extraction table?

In research, a data extraction table is the form a systematic review team fills in for each study it includes. It records the same details from every study, such as study design, participants, interventions and outcomes. It's a different thing from table extraction, which pulls tables out of documents.

See Docsumo read your own documents

Bring a few real samples. We'll show the fields extracted, the checks that ran and what a reviewer would see.