Cross-Industry & Business Teams

How Do You Extract Data From a PDF Without Losing Rows?

How do you extract data from a PDF reliably? Free tools and AI tested on 928 rows, five layouts and scans. See what broke and which checks help.

November 29, 20269 min read
Hand-drawn tweezers lifting one row out of a printed table, illustrating a test of extracting rows of data from PDFs

What matters most

  • Free PDF table tools worked perfectly on boxed tables and found nothing on several unboxed layouts.
  • pdfplumber's two settings recovered 50.6% and 59.3% of rows from our 20 digital PDFs.
  • Four AI models read between 925 and 928 of 928 rows correctly, including scanned copies.
  • AI errors were quiet single-field mistakes: a wrong month, day or digit inside a normal-looking row.
  • Totals checks miss wrong dates, so check each important field with its own rule.

You copy a table out of a PDF and it lands as one column of mush. You try a free tool and the first statement comes out perfectly. The third one silently loses half its rows, and you only find out when the totals don't tie.

That gap between "it worked on my sample" and "it works on what suppliers actually send" is the whole problem when you extract data from a PDF. So we built the PDFs that cause it and measured what survived. My short answer: free tools are fine for layouts you have tested and that don't change. For everything else, AI models read our pages almost perfectly, and you still need rules that check the result.

Here is what matters most:

  • On 928 transaction rows in 32 PDFs, Claude Haiku 5.5 and Gemini 3.1 Pro returned every row correctly. Claude Sonnet 5.5 missed 1 and Gemini 3.8 Flash missed 3.
  • pdfplumber, a popular free table reader, got 50.6% of rows from digital PDFs with default settings and 59.3% with its text setting.
  • Neither free table setting recovered a single row from the scanned copies, because a scan has no text to read.
  • A totals check can't see a wrong date. Adding a date-order check caught 3 of the 4 imperfect AI results, with no false alarms.
  • Reading cost with AI ran from under $1.50 to about $40 per 1,000 documents, and the cheapest model made no errors.

What we tested

We generated statements with made-up payees and an exact answer key, saved as normal PDFs with selectable text. Five layouts, four documents each:

  • Ruled table: one page, every cell boxed.
  • Borderless table: no cell lines, with descriptions and dates that wrap onto a second line.
  • Multi-page table: 72 rows over three pages, with "carried forward" and "brought forward" subtotals at each break.
  • Side-by-side tables: two columns of transactions on one page.
  • Bank statement: separate debit, credit and balance columns, with blanks.

We then made scanned copies of the ruled, borderless and bank layouts: grey, slightly crooked, noisy images with no text inside. That gives 20 digital PDFs with 696 rows and 12 scans with 232 rows.

Two test statements side by side: one table with boxed cells and one without cell lines, where dates wrap onto two lines
Page 1 from two of the five layouts, made by us. With default settings, pdfplumber read all 64 rows of the digital ruled set and none of the 72 borderless rows.

A row counted only if its reference, date and amount, including the sign, were all right. We ran pdftotext (a free command-line text extractor), pdfplumber with default and "text" table settings, and four AI models that accept a PDF directly: Claude Haiku 5.5, Claude Sonnet 5.5, Gemini 3.8 Flash and Gemini 3.1 Pro. The AI prompt asked for every transaction as date, reference and amount, and said nothing about subtotals or traps. Everything ran on 29 November 2026. The per-document scores are here.

Free tools: what broke

pdftotext does not build a table. It gives you text and keeps the page layout. We measured whether each row's date, reference and amount stayed together on one line. In digital PDFs, 624 of 696 rows did. All 72 failures came from the borderless layout, where each date wrapped, leaving the year on the next line. On the side-by-side layout every row survived, but each line held two transactions, so your code has to split them. On scans it returned nothing.

pdfplumber with default settings looks for ruling lines. Where tables had them, it was flawless: 64 of 64 rows on the ruled layout and 288 of 288 across the multi-page documents. Where they didn't, it found no table at all: 0 rows from the borderless, side-by-side and bank layouts. Total: 352 of 696.

pdfplumber with the text setting guesses columns from word positions. It rescued the bank statement (91 of 96 rows). On the borderless layout it cut descriptions into fragments and split every wrapped date across two rows, so no row came out whole. On the side-by-side layout it merged both tables into one row with two transactions in it. It also lost dates on some multi-page rows, ending at 259 of 288. Total: 413 of 696.

To be fair to these tools: in the digital failures we inspected, much of the text was captured. We used one general column mapping for every document. A developer who writes separate handling for each layout will do far better. The catch is the word "each". That work has to be redone when a supplier changes their template, and nothing warns you that they did.

Free table tool pdfplumber: rows it got right on digital PDFs, by layout
Default setting"Text" setting
Ruled table
64 of 64
63 of 64
Multi-page table
288 of 288
259 of 288
Bank statement
0 of 96
91 of 96
Borderless table
0 of 72
0 of 72
Side-by-side tables
0 of 176
0 of 176
One general column mapping for every document. Code written for each layout would do better.

AI models: close to perfect, not perfect

Across all 32 documents and 928 rows:

  • Claude Haiku 5.5: 928 correct. About $1.29 per 1,000 digital documents and $0.83 per 1,000 scans.
  • Gemini 3.1 Pro (preview): 928 correct. About $40.14 and $28.91. It was also the slowest, averaging 22 to 28 seconds a document.
  • Claude Sonnet 5.5: 927 correct. About $17.91 and $9.57.
  • Gemini 3.8 Flash: 925 correct. About $6.01 and $3.61, at an introductory price.
Rows returned correctly, out of 928 (digital and scanned PDFs)
Claude Haiku 5.5
928
Gemini 3.1 Pro
928
Claude Sonnet 5.5
927
Gemini 3.8 Flash
925
pdfplumber, "text" setting (free)
413
pdfplumber, default (free)
352
232 of the rows are on scans, which pdfplumber cannot read. The AI models are too close to rank.

Costs are list prices applied to the tokens used. They exclude your engineering and review time. Most test documents were one page, with the multi-page ones at three.

No model returned a subtotal line as a transaction, lost a row or flipped a sign. All four errors were quiet ones inside an otherwise correct row. Gemini Flash turned 1 June into 1 May, turned 6 July into 6 June, and read 3,789.20 as 3,889.20. Claude Sonnet read 12 June as 9 June. Each of those looks completely normal in a spreadsheet.

Please don't read this as a ranking of the AI models. With differences of one to three rows in 928, our test was too easy to separate them. We could not include OpenAI models in this run. For harder pages, including Urdu, Arabic and handwriting, where the gaps were much wider, see our LLM vs OCR test.

The checks that catch bad rows, and what they miss

Extraction you can't check is extraction you have to redo by hand. We ran two rules on every result, both a few lines of ordinary code.

Rule 1, totals: do the extracted amounts add up to the statement's own net total, or to the change between opening and closing balance?

Rule 2, date order: are the dates in the order a statement would list them, never going backwards?

On the 4 AI results with an error:

  • The totals rule caught 1, the wrong amount.
  • The date rule caught 2 of the wrong dates.
  • Together they caught 3. Claude Sonnet's 9 June passed both, because it still sat in order.
  • Neither rule flagged any of the 124 AI results that were fully correct.

On the free tools the totals rule earned its keep: it flagged all 24 imperfect results from pdfplumber's default setting. With the text setting it caught only 16 of 24, because rows with lost dates still added up. The date rule caught the other 8.

The lesson is not "add a totals check". It's that each field needs its own rule. On a bank statement, checking the running balance row by row would pin an amount error to a single line. For dates, check the statement period and the order. Whatever no rule covers is what a person has to look at.

Which should you use?

One layout, digital PDFs, from a system that rarely changes: start with pdfplumber or pdftotext. It's free, fast and runs on your own machine. Add the checks above so you notice the day the layout changes.

Many layouts, scans or photos: use an AI model that reads the PDF, with the same checks. Test the cheap models first, because in this run the cheapest one made no errors. That isn't a rule: in our tax form test, the cheapest model we tried made the most errors.

Records that can't leave your network: that rules out most hosted services, so settle it first. You can run AI models inside your own cloud account under business data terms, which some firms accept and others don't. Keep the source PDF one click from every extracted value, and log who approved what.

In every case, a person should see the rows the rules flag and a sample of the rows they pass. The software does the typing and the checking. Your team decides what the exceptions mean. For what that review costs, see LLM document processing cost per page, and for the manual alternative, data entry outsourcing vs AI.

What this test does not show

These PDFs were generated by us, in English, with one template per layout and one font. Our scans were mild. Real files have stamps, merged cells, handwriting, rotated pages, fax noise and tables that break mid-row. We did not test Camelot, Tabula or paid document services such as Amazon Textract or Google Document AI. We ran each model once per document. A clean result here means a method passed an entry test, not that it will pass yours.

FAQ

What is the easiest way to extract data from a PDF for free?

For a digital PDF with boxed table cells, pdfplumber's default setting read every row in our ruled and multi-page tests. Without cell lines it found no table. For plain text with layout kept, pdftotext works well. Neither reads a scan.

Can AI extract tables from a PDF accurately?

On our 32 statements, four AI models returned between 925 and 928 of 928 rows correctly. Real documents are harder than ours, so test on your own files and keep rule checks in place.

How do I extract data from a scanned PDF?

A scan is a picture, so you need text recognition or an AI model that reads images. Free table tools recovered no rows from our scans. All four AI models read them at 99.6% to 100% of rows.

How do I know the extracted data is correct?

Check it with rules built on the document itself: totals, running balances, date order, date range and reference formats. Send anything that fails to a person, with the source page beside it.

Test it on your own PDFs

If your team still retypes statements, invoices or reports, we can run this test on a sample of your real files and show you which rows each method gets wrong. See document data extraction, or book a free call and bring your worst PDF.

Cross-Industry & Business TeamsLLM vs OCR: Which Reads Scans and Handwriting Better? We TestedCross-Industry & Business TeamsWhat Is a Reserve Study, and What Should Your Board Do With It?Cross-Industry & Business TeamsWhy Does n8n PDF Extraction Break? We Coded 52 Questions