Short answer: OCR invoice extraction works best as three jobs: read the document, validate its business data, and send it to a person when a critical field is uncertain or the totals do not reconcile. Read embedded text when a PDF has a reliable text layer, and use OCR for scans and photos.

Think in stages

  1. Intake. Accept the formats you expect, enforce size limits, detect duplicates by file hash, and reject anything unsafe.
  2. Text extraction. Digital PDFs often contain real text that can be read directly. Scans and photos need OCR or a vision model.
  3. Field extraction. Turn text and layout into structured fields.
  4. Validation. Check the fields against rules that a correct document must satisfy.
  5. Routing. Send clean results straight through and uncertain ones to a person.
  6. Review and approval. A human corrects and signs off.
  7. Export and audit. Deliver the approved data and keep a record of every change.

How do you choose between PDF text, OCR and vision models?

Start with the document type and layout. Native PDF parsing can preserve text and tables on digital invoices. For scans, local OCR and layout tools such as PaddleOCR and Docling let you process documents on infrastructure you control. Budget for compute, maintenance and review. Managed invoice parsers return normalized fields and line items. A vision-language model can help with layouts the primary extractor struggles with. Compare options on your suppliers, languages and scan quality, and check the provider’s data handling terms before sending invoices off-site. If you call a model as a fallback extractor, send those calls through one place; see one LLM gateway for several providers.

Sources: Docling usage · PaddleOCR layout pipeline · Document AI processors

What schema should invoice extraction use?

Define a versioned invoice schema with invoice number, supplier ID, issue date, currency, line items, subtotal, tax, total and amount due. Keep the original string and the page or bounding box when the extractor provides them. Use decimal amounts, preserve leading zeros in invoice IDs, and mark missing fields explicitly. Route purchase orders to their own schema. Schema validation checks the output shape. Reconciliation and evidence checks establish whether the values can be accepted.

Sources: Azure invoice field reference · Amazon Textract AnalyzeExpense

Which validation rules catch bad invoice data?

Reconcile quantities and line amounts, then apply the invoice’s discounts, charges and taxes under its currency and rounding policy. Check tax-inclusive invoices, credits and partial payments under the rules that apply to that document type. Compare a normalized supplier and invoice number within the tenant to detect possible duplicates across rescans. Use the file hash for exact byte copies. Where purchase orders are part of the workflow, match the invoice to the purchase order and receipt as required.

Worked example: a total that does not reconcile

Example using synthetic data. An invoice shows a USD 100.00 subtotal and USD 8.00 tax. The OCR reads the total as USD 180.00. The reconciliation rule expects USD 108.00 and sends the invoice to review. The reviewer checks the highlighted total on the source page and corrects it to USD 108.00. The pipeline reruns validation before export.

When should an invoice go to human review?

Use hard business rules to stop automatic approval when required fields, duplicate checks or totals fail. Calibrate confidence thresholds on labeled samples by field and extractor. Prioritize critical fields such as supplier identity, invoice number, currency and total. Route conflicting or missing evidence to review. Track error rates among auto-approved invoices by auditing a sample, and revisit thresholds when supplier layouts or extraction models change.

How should the review queue and export work?

Show the original page beside extracted values, highlight the source evidence for flagged fields and show the failed rules. Revalidate corrections and keep the original values alongside the approved version in the audit history. Record who approved the invoice, when, and which schema and extractor versions were used. Track export separately from approval. Reuse the same export key for retries of the approved invoice version and persist the accounting record ID. After a timeout, reconcile with the destination before retrying. Route changes to posted invoices through its correction workflow.

Use separate jobs for retryable stages. Authorize source access per tenant. Treat uploaded text as untrusted when sending it to a language model. How jobs and workers fit into a FastAPI and Next.js product is covered in AI SaaS architecture.

How do you measure invoice extraction?

Metric How to measure it
Critical field accuracy Compare normalized values against labeled data for each field. Break results down by supplier, language and scan quality.
Auto-approval rate Divide auto-approved invoices by eligible invoices. Record the eligibility rules and denominator.
Auto-approval error rate Audit a sample of auto-approved invoices and report the share with material errors alongside the sample size.
Review and export Track review time, corrections by field, failed exports and duplicate export attempts.

Privacy and compliance

Invoices contain names, addresses, bank details and tax numbers. Decide how long documents and extracted data are kept, encrypt them at rest, limit who can open them, and understand each provider's data handling terms before sending documents to it. For regulated customers, the location of processing may matter as much as the accuracy.

Roll it out in steps

Start with one document type and one supplier group. Run the system in shadow mode first, producing results next to the manual process so you can compare without risk. Widen the scope as the numbers justify it, and keep the human review in place for anything the rules do not clearly clear.

Related guides

Frequently asked questions

Do I need OCR if my invoices are digital PDFs?

Often not. A PDF with a reliable text layer can be read directly. Use OCR for scans and photos, and check the text layer on a sample of your invoices before you rely on it.

Can a language model extract invoice fields on its own?

It can help with layouts that your primary extractor struggles with. Validate its output the same way as any other: against your schema, the totals and the duplicate checks, with human review for uncertain fields. Check the provider's data handling terms before sending invoices off-site.

When can an invoice be approved automatically?

Only when the required fields are present, the duplicate and total checks pass, and confidence is above thresholds calibrated on labeled samples. Audit a sample of auto-approved invoices to track their error rate.

Where to go next

If you would rather start with the pipeline built, the AI agent boilerplates category lists BoilerShelf's Document Workflow Delivery Kit. Whatever you choose, test it on your own invoices and measure the figures above before you rely on it.

The idea in short

A document enters through an intake step, is converted to text by OCR or a vision model, and is extracted into a fixed schema. Validation rules check the result, and confidence signals decide whether it goes straight through or to a review queue. A reviewer corrects and approves, and the approved data is exported with a record of who changed what.

Patterns covered: Schema-first extraction · Validation rules · Human-in-the-loop review · Audit trail

Originally published at boilershelf.com.