botttaStart project

PDF Data Extraction: A Build Guide for Lean Teams

Ugo Charles
Illustration for PDF Data Extraction: A Build Guide for Lean Teams

You point a script at a folder of 200 PDFs. Half come back perfect, every field where you expect it. The other half come back empty, or worse, as a scramble of characters that looks like the file got dropped down the stairs. Same folder, same code, wildly different results.

That is the whole problem with PDF data extraction in one image. The word "PDF" hides at least three different kinds of file, and each one needs a different method. Run the wrong one and you get blanks, garbage, or fields that are mostly right with a few quietly wrong, which is the most expensive outcome of all.

The fix is not a smarter tool. It is matching the method to the file in front of you, then wrapping the read in the unglamorous parts that make it hold up in production: a confidence gate, a clean write-back, and monitoring. The examples below lean on invoices, statements, and forms because that is what most teams re-key by hand, but the same approach extracts data from lab results, shipping docs, contracts, or any PDF stream your operation drowns in.

First, figure out which of three PDFs you're holding

Before you pick a tool, pick up one of the files and answer a single question: can you select the text with your cursor and copy it?

If you can, it is a native PDF. The text is a real layer in the file, put there when someone exported from Word, a browser, or an accounting system. Extraction here is close to free, because the data is already text. A library reads it.

If you try to select and the whole page highlights like a photo, it is a scanned PDF. It is an image of a page with no text underneath. Every character your eye reads is invisible to a computer until you run optical character recognition, OCR, to turn the pixels back into text.

The third kind is the one that eats projects: a structured-but-messy PDF. It might have a text layer or it might be scanned, but the value is locked in tables, multi-column layouts, or key-value fields (invoice number here, total there, a line-item grid below) that vary from vendor to vendor. Plain text extraction pulls the words but loses which number goes with which label.

Sort a sample of 20 real files into those three buckets before you write a line of code. That sort is the same data-readiness check any automation starts with, and here the mix decides your entire pipeline and your entire bill. A team re-keying native PDFs has a five-line problem. A team re-keying scanned, varied invoices from 50 vendors has a real one.

Match the extraction method to the PDF, not the other way around

The mistake is picking a tool first and forcing every PDF through it. Pick the file type first. Then the method is almost decided for you.

Native PDFs: use a text-parsing library like pdfplumber or pdf.js. No OCR, no API bill, just compute. If most of your stream is native, do not pay per page for anything. You already have the text.

Scanned PDFs with plain text: you need OCR. AWS Textract's Detect Document Text API runs $1.50 per 1,000 pages and drops to $0.60 per 1,000 after your first million pages a month. Google's Document AI Enterprise OCR is priced the same at $1.50 per 1,000. That is cheap enough that OCR cost is rarely the thing that decides the build.

Tables and key-value fields: this is where the price jumps and where naive OCR falls apart. Textract's Analyze Document adds structure detection: Tables at $15 per 1,000 pages, Forms at $50 per 1,000, Queries at $15 per 1,000, or the combined Forms plus Tables plus Queries at $70 per 1,000, all per Textract's pricing page. Google's Document AI Form Parser is $30 per 1,000. That is a 10x to 47x jump over plain OCR, and it is the single line item teams miss when they estimate a project on the OCR rate.

Varying layouts that need judgment: a large language model with vision. When every vendor's invoice looks different and no fixed template holds, a model that reads the whole page and returns structured JSON earns its cost. Claude Haiku 4.5 runs $1 per million input tokens and $5 per million output, and Claude Sonnet 5 is $3 and $15 as of September 2026. Anthropic's own docs put a 500 kB research-paper PDF at roughly 125,000 tokens, so cost scales with how image-heavy the file is, not with a flat per-page rate.

Here is the decision in one table.

| PDF type | What it needs | Tool | Rough cost | |---|---|---|---| | Native (text layer) | Text parse, no OCR | pdfplumber, pdf.js | Compute only | | Scanned, plain text | OCR | Textract Detect Text, Google Enterprise OCR | $1.50 / 1,000 pages | | Tables + key-value | Layout-aware parse | Textract Forms/Tables ($15-$70 / 1,000), Google Form Parser ($30 / 1,000) | $15-$70 / 1,000 pages | | Varying layouts | LLM vision | Claude Haiku 4.5 ($1/$5), Sonnet 5 ($3/$15) per MTok | Token-based, file-size driven |

The stance most guides dodge: for a high-volume stream of plain scans, OCR at $1.50 per 1,000 beats an LLM on cost and speed, full stop. Reach for the model only when layouts vary enough that a template breaks. Paying Sonnet token rates to read a page a $1.50-per-1,000 OCR call would have handled is how a "cheap" pipeline turns into a surprise invoice. This is the same match-method-to-input logic we walk through for every input type in our data-entry guide.

Deal with the tables and fields that refuse to sit still

Plain OCR gives you a wall of text in reading order. That is fine for a paragraph and useless for a table, because "1,240.00" three lines down means nothing without the column header it belonged to. Getting structure back is the actual work of PDF extraction.

Three problems show up over and over:

  • Multi-column layouts get read straight across, interleaving two columns into nonsense. Layout-aware parsing (Textract's Forms and Tables, Google's Form Parser, or an LLM that sees the page) keeps columns apart.
  • Line-item tables with a variable number of rows are the classic invoice killer. You do not know if there are 3 rows or 30 until you read it, so you cannot hard-code positions. This is exactly what the Tables and Form Parser APIs exist for.
  • The same field in a different place on every vendor's template is where fixed-coordinate extraction dies. Template-per-vendor works for 5 vendors and collapses at 50. Past that count, an LLM that finds "the invoice total" by meaning instead of by position is usually the cheaper build to maintain, even at token rates.

Pick your method here by counting your templates, not by chasing the fanciest tool. Under roughly a dozen stable layouts, a layout-aware parser with light per-vendor rules is cheaper to run and easier to debug. Past that, the model earns its keep. The related move for on-screen data that never becomes a clean file at all is screen-based RPA, which we would generally avoid for PDFs when an OCR or parse API can read the file directly.

Put a confidence gate before anything writes to your system

No extractor is 100% right, and the failures are silent. A misread "8" as a "3" on an invoice total does not throw an error. It just posts the wrong number into your ledger and waits to be found at month-end. The gate is what separates a pipeline you can trust from one that quietly corrupts your data.

Every serious extraction API returns a confidence score per field. Textract and Document AI both do. Use it. The rule that has held up across the builds we ship:

  • High confidence on required fields: write it through automatically.
  • Low confidence on any required field, or a failed validation check: route the whole record to a human review queue before it goes anywhere near your system of record.

Then add cheap validation that has nothing to do with confidence scores. Does the invoice total equal the sum of line items? Is the date a real date and not in 2087? Does the vendor name match one you have on file? These checks catch the confident-but-wrong extractions that a score alone will miss. A field can be extracted with 99% confidence and still be the wrong field.

Set the threshold by stakes. A dollar amount posting to your books deserves a high bar and a human check on anything shaky. An address field feeding a mailing list can run looser. This is the same frequency-and-stakes call we lay out in when to automate a task and when not to: the higher the cost of a wrong value, the more review you build in.

Write to the source of truth and confirm it landed

Extraction is only half the job. The data has to arrive in the system that owns it, whether that is your CRM, your accounting tool, or a database, and it has to arrive exactly once.

Write through the system's API, not by dropping a CSV for someone to import. An invoice pipeline that extracts perfectly and then parks a file in a folder has automated the reading and left the re-keying. Push the structured fields straight into the API that owns the record.

Two details save you from the failures that show up at scale:

  • Idempotency. Key each record on something stable from the document, like an invoice number, so a retry or a duplicate PDF does not post the same charge twice. Without it, the day your job runs twice is the day you double-bill.
  • Confirmation, not fire-and-forget. Read back the API's response and log the created record's ID. If the write fails, the record goes to the same review queue as a low-confidence extraction, not into a silent void. A pipeline that cannot tell you what it wrote is a pipeline you will stop trusting the first time a number goes missing.

Common mistakes that turn a working extractor into a mess

The demo works on 10 hand-picked PDFs. Production is where it breaks, and it breaks in predictable ways.

  • Estimating cost on the OCR rate. You price the job at $1.50 per 1,000 pages, then discover you need Forms and Tables at $70 per 1,000 to get usable structure. The real number is often 10x your first guess. Price the method you actually need.
  • No confidence gate. Auto-writing every field means the small share that come back wrong flow straight into your system and surface weeks later as a reconciliation headache. The gate is not optional.
  • Hard-coding field positions. It works until a vendor moves their logo or adds a line. Extract by label or meaning, not by coordinates, once you are past a handful of fixed templates.
  • No monitoring. A workflow that silently fails is worse than no workflow, because you stopped checking by hand the day you turned it on. Alert on extraction failures, on records piling up in the review queue, and on volume that suddenly drops to zero.
  • Ignoring the native PDFs in the pile. Paying per page to OCR files that already carry a clean text layer is pure waste. Route native PDFs to the free path first.

Most of these come down to treating a demo as a pipeline. The reading is the easy 20%. The gate, the retries, the monitoring, and the write-back are the 80% that makes it survive contact with real files.

When to build this yourself, and when to bring in bottta

If your stream is mostly native PDFs, or scanned files with one or two stable layouts, build it yourself. A pdfplumber script or a single Textract call with a confidence check is a genuine afternoon of work, and you should own it. We would rather tell you that than sell you a project you do not need.

Bring in a studio when the shape gets hard: dozens of vendor templates, a mix of native and scanned in the same stream, line-item tables that have to reconcile, or a write-back into a system where a wrong number has real cost. That is the work bottta does. We map the PDF stream, sort it by type so you are not overpaying for OCR you do not need, build the extraction with a confidence gate wired to a real review queue, connect the write-back into your CRM or accounting tool with idempotency and confirmation, and monitor the thing once it is live.

Two ways to work with us. A fixed-scope build, integrations included, runs as a $4K project with 30 days of post-launch support, which fits a defined pipeline like "extract these invoices into QuickBooks." If your PDF streams keep shifting or you want us owning extraction alongside your other automations, the $3K per month retainer covers flexible hours across up to three active workflows with ongoing monitoring and fixes. Either way you get a pipeline you own, not a template you babysit.

The reading was never the hard part. The confidence gate, the idempotent write-back, and the monitoring are what decide whether you can stop opening these files by hand, and they are the parts a demo always skips. That is the build bottta ships and keeps watching. For the wider tool landscape around this one pipeline, our rundown of document automation software maps the rest of the category, and if your job runs the other direction, turning clean data back into formatted files, generating PDF reports is the sibling build. Start a project with bottta when you want the pipeline running instead of babysat.

Frequently asked questions

What is the difference between a native PDF and a scanned PDF?

A native PDF has a real text layer, added when it was exported from software, so a computer can read the text directly and extraction is nearly free. A scanned PDF is an image of a page with no text underneath, so you need OCR to turn the pixels back into readable characters before you can extract anything. The fastest way to tell them apart is to try selecting text with your cursor. If the whole page highlights like a photo, it is scanned.

How much does PDF data extraction cost?

It depends entirely on the file type. Native PDFs cost only compute. Scanned text runs about $1.50 per 1,000 pages on AWS Textract or Google Document AI. Structured extraction with tables and key-value fields jumps to $15 to $70 per 1,000 pages on Textract or $30 per 1,000 on Google's Form Parser, per each vendor's pricing page. A language model like Claude Haiku 4.5 ($1 and $5 per million tokens) bills by token, which scales with how image-heavy each file is rather than a flat per-page rate.

Can I use ChatGPT or Claude to extract data from PDFs?

Yes, and it is the right tool when layouts vary so much that a fixed template breaks, because a vision model reads a page by meaning instead of by position. It is the wrong tool for a high-volume stream of plain scans, where OCR at $1.50 per 1,000 pages is cheaper and faster. Match the method to the file: model for varied, judgment-heavy layouts, OCR for volume.

How accurate is automated PDF extraction?

Accurate enough to trust only when you gate it. No extractor is perfect, and the errors are silent, so the accuracy that matters is your pipeline's, not the tool's. Use the per-field confidence scores that Textract and Document AI return, add validation checks like "total equals the sum of line items," and route anything shaky to a human before it writes to your system. That combination, not a raw accuracy percentage, is what makes the output safe to post.

Do I need OCR for every PDF?

No. OCR is only for scanned, image-based PDFs. Native PDFs already carry a text layer you can read directly with a library at no per-page cost. Sending native files through OCR is wasted money, so sort your stream by type first and route each file down the cheapest path that works.

More from the Journal