How to Use AI to Extract Data from PDF Tables and Forms

How to Use AI to Extract Data from PDF Tables and Forms

Use AI to pull data out of PDF tables and forms: prepare the input, ask in ways that expose errors, and verify every figure before you rely on it.

Pulling a table out of a PDF into something you can calculate with is one of the jobs language models are genuinely good at — and one where a plausible wrong answer is worst, because a mis-read figure in a spreadsheet looks exactly like a right one. The method matters less than the checking.

Why PDF tables are hard in the first place

A PDF does not contain a table. It contains text drawn at coordinates, and sometimes lines drawn near that text. The grid you see is an illusion your eye assembles.

Nothing in the file says "this cell belongs to this row and this column". Any tool recovering a table is inferring structure from position — which is why extraction breaks on merged cells, multi-line cells, tables spanning pages, and tables with no ruling lines at all.

This is also why models help: inferring structure from messy layout is the kind of judgement they are suited to. And it is why they fail in a specific way — they will confidently produce a well-formed table that does not match the page.

Get the input right first

Check there is a text layer. Try to select a number in the table. If nothing highlights, the PDF is a scan and there is no text to extract — you need OCR first. This site's editor does not do OCR; use a dedicated tool for that step.

Extract the relevant pages. Accuracy on one table is much better than accuracy on a 200-page report. Pull out the pages you need and work on those.

Keep the original. Always. You will be comparing against it.

Ask in a way that makes errors visible

Some prompt patterns are markedly more reliable than others:

  • Ask for a specific format. "Return this table as CSV with the original column headers" beats "extract the table". Ambiguity is where invention creeps in.
  • Say what to do with blanks. "Use an empty string for blank cells, do not guess a value." Without this, gaps get filled plausibly.
  • Ask for the row count first. "How many data rows are in this table?" Then check the output has that many. A dropped row is the most common and least visible failure.
  • Do not ask for arithmetic. Extract the numbers, then calculate in a spreadsheet. A model doing sums on values it has just read compounds two error sources into one unverifiable figure.
  • Take one table at a time. Multiple tables in one request invites merging.

The verification step is not optional

Treat everything extracted as unverified until you have checked it. A short, practical routine:

  1. Row and column counts against the original.
  2. Totals. If the table has a total row, sum the extracted column and compare. This catches most misreads in one step.
  3. Spot-check the extremes. The largest and smallest values, and anything with unusual formatting — negatives in parentheses, currency symbols, thousands separators, footnote markers stuck to figures.
  4. Check the headers. Shifted headers silently mislabel every column beneath them.

If there is no total to check against, add one: sum a column you can also sum by eye on the page.

Forms are a different job

For a fillable form with real fields, do not use a model at all. The values are already structured data — export them as FDF, XFDF or CSV from a PDF tool and you get exactly what was entered, with no inference and no risk.

Use extraction only for flat forms: a scan, or a printed layout where the answers are just text on the page. There, the same verification rules apply, with extra care on handwriting.

Frequently asked questions

How accurate is this? Good on clean, ruled, single-page tables; unreliable on merged cells, multi-page tables and dense financial layouts. Accuracy is not something to assume — verify per document.

Can I extract from a scanned PDF? Only after OCR. There is no text to extract from an image.

Why did it invent a row? Because it inferred structure that was not there, usually around a merged or blank cell. Asking for the row count up front makes this visible immediately.

What format should I ask for? CSV for spreadsheets, JSON if you are feeding code. Specify it explicitly.

Is it safe to upload confidential documents? Check the terms of the service and your own organisation's policy before uploading anything sensitive. If the answer is no, use a local extraction tool instead.

Usama Ramzan
Written byUsama RamzanFounder, Online PDF Edits

Usama Ramzan is the founder of Online PDF Edits, a browser-based PDF editor built to change text, images, and tables in existing PDFs without breaking their fonts, spacing, or multi-page layout. He writes about practical PDF editing, document workflows, and the engineering behind layout-safe editing.

Recommended reading

View all articles →