Document Understanding: Receipts, Forms, and PDFs
Read invoices, receipts, IDs, and multi-page PDFs into structured data — native PDF input vs. OCR, page-level citations, and human review for edge cases.
Documents are where vision features meet money. A refund request comes with an invoice PDF. An expense claim comes with a crumpled receipt photographed on a kitchen table. A new enterprise customer sends a signed order form and a tax exemption certificate. Somebody has to read each one and type the numbers into a system, and a single misread digit in a total turns into a wrong refund.
Models can now read all of these, including scans, photos, and multi-page PDFs, and return structured data. The hard part is making that data trustworthy. In this lesson you'll build Deskmate's billing-document reader: decide between native PDF input and text extraction, pull an invoice into a schema where every value carries page-level evidence, verify that evidence and the arithmetic in code, and route the doubtful cases to a person.
Know which kind of document you have
"Document" covers several very different inputs, and the right technique depends on which one you're holding:
| Kind | Examples | What's actually in the file | Main risk |
|---|---|---|---|
| Born-digital PDF | Invoices from billing systems, contracts exported from a word processor | A real text layer: the characters are stored in the file | Layout: tables, columns, and headers that text extraction scrambles |
| Scanned PDF | A signed form run through an office scanner | Page images, with no text, or with a low-quality OCR layer someone else added | Misread characters, skew, stamps over text |
| Photo | A receipt shot on a phone | A single JPEG, often rotated, curved, or shadowed | Everything above, plus glare and partial crops |
| Structured form | Tax forms, order forms, applications | Fixed fields, checkboxes, signatures | Checkbox states and handwriting |
OCR (optical character recognition) is the classic technique for turning page images into text. A vision-capable language model does something broader: it reads the text and understands the layout around it, so it knows the "Total" next to "$1,240.00" belongs to the whole invoice, not to the last line item.
One category deserves a warning up front: identity documents. You can extract the name and expiry date from a photo of a driver's license, but extraction is not verification. A vision model can't reliably tell a genuine document from an edited or AI-generated one, and identity checks often carry legal obligations. Use a dedicated identity-verification provider for that job, and talk to a lawyer about your obligations.