DEV Community

Cover image for OCR is a step, not a guarantee (turning scanned archives into usable data)
Fabien Kost
Fabien Kost

Posted on Originally published at closiqode.com

OCR is a step, not a guarantee (turning scanned archives into usable data)

Adapted from an article originally published in French on closiqode.com.

Running OCR over scanned PDFs, images or archives does not make them usable on its own. To get there, you need searchable text, a permanent link to the original, a structure for the information that matters, and a check on the uncertain cases.

OCR reads the document. The data only becomes useful once it finds its place in a structure.

A digital archive can be as opaque as a filing cabinet

A tall stack of cream paper scans bound with dark string on a black studio table, a single sheet at the top catching a thin orange amber light: an archive that is stored but not yet readable

Scanning a document protects the physical medium and makes it easier to share. It does not turn its content into data. An image sitting in a folder is still hard to search, compare or connect to a business application.

The confusion usually comes from four different operations being treated as one:

  • Digitizing creates an image.
  • OCR recognizes the characters.
  • Indexing makes the content searchable.
  • Structuring turns specific elements into usable fields.

Each step answers a different need.

You may already have thousands of well-named scans. Yet finding a reference, a date or a measurement still means opening files one by one. The knowledge exists, but it is stuck on the page. You see this gap in technical archives, customer files, field reports and old invoices: storage is solved, usage is not. So the project has to start from the next expected action, not from the volume to digitize.

OCR is a step, not a guarantee

The French National Library (BnF) describes a chain that combines preprocessing, segmentation and recognition. It also stresses the impact of contrast, orientation, smudges, columns and illustrations. A sound setup therefore keeps the source image and ties the extracted text to its page.

For business use, add sampling checks and consistency rules. An impossible date, an unknown unit or a total that does not add up must raise an alert rather than be imported silently. As an example, in Python:

from datetime import date

KNOWN_UNITS = {"mm", "cm", "m", "kg"}

def check_record(rec):
    """Return a list of issues; a non-empty list sends the record to review."""
    issues = []
    if rec.doc_date and rec.doc_date > date.today():
        issues.append("document date is in the future")
    if rec.unit not in KNOWN_UNITS:
        issues.append(f"unknown unit: {rec.unit!r}")
    if rec.lines and abs(sum(l.amount for l in rec.lines) - rec.total) > 0.01:
        issues.append("line amounts do not add up to the total")
    return issues
Enter fullscreen mode Exit fullscreen mode

Each flagged record goes to a review queue with its file and page reference, so the reviewer looks at the original instead of trusting the extracted text.

Design the output before processing the backlog

Need Useful output Priority check
Find a file Full-text index OCR quality and metadata
Compare values Structured table Units and context
Detect an anomaly Alert with evidence Business rule and source page
Query the archive Search engine or assistant Access rights and citations

The system can process the normal case automatically and isolate the exceptions: unreadable page, incomplete document, handwriting, unusual table or contradiction. That human review queue makes the project more reliable and easier to improve over time.

Step 1: know what you are looking for

Digitizing everything without a precise goal can simply produce a bigger digital backlog. Decide:

  • which pieces of information have value;
  • how they will be used;
  • who needs access;
  • in what form they must come out.

Step 2: separate reading from understanding

Recognizing "12.4" in an image is one thing. Knowing that 12.4 is a specific measurement, in a specific context, with a defined tolerance, is another.

That layer of logic is exactly what a business application adds on top of OCR.

Step 3: plan for exceptions

Old documents. Poor quality. Missing pages. Different fields. Contradictory data.

The system must be able to report the situations it cannot handle, instead of guessing.

Step 4: make the data usable in your tools

The output can take several forms:

  • a spreadsheet;
  • a search engine;
  • an alert;
  • a structured database;
  • a dashboard;
  • an API;
  • a business assistant.

The best output always depends on what has to happen next.

From archived image to controlled data: five levels

Five sheets of cream paper arranged like a staircase on a dark surface, each step slightly more orderly than the previous one, the top sheet lit in orange amber: the progression from stored image to controlled data

Level What becomes possible What is still missing
1. File stored Opening the document if you know where it is Search in the content and reliable context
2. Text recognized Searching for words after OCR Structure, error correction, link between a value and its role
3. Document indexed Filtering by type, date, folder or entity Business fields comparable across documents
4. Structured data Sorting, comparing, exporting, feeding an application Quality rules, exceptions and proof of origin
5. Controlled data Triggering a workflow with targeted review of uncertain cases Continuous tracking of errors, versions and new formats

The right goal is not necessarily level 5 for every archive. Choose the level that enables the intended use, then keep the link to the original so any important value can be checked.

FAQ

Is OCR enough to query an archive?
No. It gives you text. You still need to index that text, manage metadata and access rights, and keep the link to the source.

Do all OCR errors need manual correction?
Not necessarily. You can focus review on critical fields and on results below a confidence threshold.

Can tables and forms be processed?
Yes, but their structure must be tested on every variant. A shifted row can change the meaning of a value.

Should the original files be deleted?
No. The original remains the reference, kept according to your legal obligations and archiving policy. The extracted data is an extra layer on top of it.

Storage is solved, usage is not

If your archives are digitized but still hard to use, the problem is probably less about storage and more about the missing tool between the page and the decision.


I am Fabien Kost, an independent developer in France (ClosiQode). I turn scans and archives into checked tables and databases that keep a link to every source page. More on how I approach document extraction (in French).

Sources (in French): BnF, text conversion techniques and formats and mass digitization, quality and formats.

Top comments (0)