Prompt

How do I use OCR to read scanned documents and save the fields?

Technology / Data Infrastructure1 observationLast seen Oct 11, 2026

Latest observation

Oct 11, 2026OpenAI APIWeb search: off

To use OCR for scanned documents and save fields, the typical workflow is:

1) Scan or collect the document

  • Input can be PDF, TIFF, JPG, PNG, etc.
  • If possible, scan at 300 DPI or higher for better OCR accuracy.

2) Preprocess the image

Improve OCR results by:

  • Deskewing tilted pages
  • Removing noise
  • Increasing contrast
  • Cropping unnecessary borders
  • Converting to grayscale

3) Run OCR

Use an OCR engine to extract text from the image/PDF. Popular options:

  • Tesseract (open source)
  • Google Cloud Vision
  • AWS Textract
  • Azure Document Intelligence
  • EasyOCR / PaddleOCR

4) Extract the fields you care about

Once you have text, map it to structured fields such as:

  • Name
  • Date
  • Invoice number
  • Total amount
  • Address

Ways to do this:

  • Template-based extraction: if all forms look the same
  • Regex/parsing: for fields with predictable patterns
  • ML/document AI: for variable layouts

5) Save the fields

Store the extracted data in:

  • JSON
  • CSV
  • SQL database
  • NoSQL database
  • CRM/ERP system

Example with Python and Tesseract

Install

pip install pytesseract pillow pandas

You also need to install the Tesseract OCR engine on your system.

OCR a scanned image

from PIL import Image
import pytesseract

image = Image.open("scanned_doc.png")
text = pytesseract.image_to_string(image)
print(text)

Extract fields from the OCR text

Example for a simple invoice:

import re

fields = {}

match = re.search(r"Invoice No[:\s]*([A-Z0-9-]+)", text, re.IGNORECASE)
if match:
    fields["invoice_number"] = match.group(1)

match = re.search(r"Total[:\s]*\$?([\d,]+\.\d{2})", text, re.IGNORECASE)
if match:
    fields["total"] = match.group(1)

print(fields)

Save to JSON

import json

with open("output.json", "w") as f:
    json.dump(fields, f, indent=2)

If your documents have a fixed layout

Use coordinates to read fields from specific regions:

  • OCR each region separately
  • Or use a document AI tool that returns text + bounding boxes

This works well for:

  • Standard forms
  • IDs
  • Invoices with consistent templates

If your documents vary a lot

Use a document understanding service:

  • AWS Textract for forms/tables
  • Azure Document Intelligence
  • Google Document AI

These can directly detect key-value pairs and tables.


Best practice

  • Start with OCR + regex for a simple prototype
  • Use document AI if accuracy/layout complexity is high
  • Validate extracted fields before saving
  • Keep the original document and OCR output for audit/debugging

If you want, I can give you:

  1. a Python script that processes PDFs and saves fields to CSV/JSON, or
  2. an example using AWS Textract / Azure / Google Document AI.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.