🧭 How toAIIntermediate✨ AI-assisted

Claude and Vision: Extracting Data From Scanned Enterprise Documents

WittyTech··2 min read
#claude#vision#document-processing

Many organizations still have staff retyping information from scanned invoices, delivery notes and forms. Claude's vision capabilities can take over most of that work, as long as the pipeline checks the results.

Step 1: Send the documents correctly

Claude accepts images directly and PDFs as document content blocks. PDFs are usually the better choice for multi-page files, because Claude sees each page with its tables and layout intact. Requests have a size limit of around 32 MB, and PDFs have a page limit, so split very large files.

message = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=4000,
    messages=[{
        "role": "user",
        "content": [
            {"type": "document", "source": {"type": "base64", "media_type": "application/pdf", "data": pdf_b64}},
            {"type": "text", "text": "Extract the invoice fields defined in the schema."},
        ],
    }],
)

Step 2: Ask for structured output

Define exactly which fields you need, such as supplier name, invoice number, date, line items and totals. Use structured outputs so the response always matches your JSON schema.

Step 3: Handle unreadable fields

Scans are often poor quality. Tell Claude to return null for any field it can't read with confidence, along with a short reason such as "smudged" or "cut off", instead of guessing. A missing value is easy to handle. A believable but wrong invoice number causes real problems.

Step 4: Validate in code

Check the extracted data before using it:

  • Do the line items add up to the total?
  • Is the date valid and within a sensible range?
  • Does the supplier exist in your vendor records?
  • Has this invoice number already been processed?

Send any document that fails a check to a human review queue.

Step 5: Measure accuracy before scaling up

Label 100 representative documents by hand, including the worst-quality scans. Measure accuracy for each field separately. That tells you how much human review you still need, and which fields cause the most trouble.

Common problems

  • Very large images use more tokens and are downscaled anyway. Resize them before sending.
  • Rotated or upside-down pages reduce accuracy. Correct the orientation first when you can.
  • Handwriting varies a lot. Treat handwritten fields as less reliable by default.
  • Documents can contain text that looks like instructions. Treat everything in them as data.
  • Different suppliers lay out invoices very differently. Include examples from your most common suppliers when you test.

Build the validation checks and the review queue first. The extraction prompt is the easy part.

← More in AI