(RAFAYGEN_AI)
Sign up free

Digitize Urdu books with AI OCR: scans to searchable, editable text

Optical character recognition is a solved problem for English and an actively hard one for Urdu. If you have tried to run a scanned Urdu book through a general-purpose OCR tool and got back a page of garbage, that was not your fault and it was not a settings mistake.

This explains why Urdu is genuinely difficult for machines to read, how to prepare your scans so the result is usable, what the realistic accuracy is, and how to proofread the output efficiently rather than retyping the book.

Why Nastaliq breaks ordinary OCR

Latin OCR works by segmenting a line into discrete character shapes and classifying each one. Almost every assumption in that sentence fails for Urdu.

Urdu is written in Nastaliq, a cursive style where letters join, and a letter's shape changes depending on whether it is at the start, middle or end of a word, or standing alone. There is no reliable boundary between one character and the next to segment on.

Worse, Nastaliq is written on a steep diagonal baseline. Words cascade down and to the left, and successive words overlap vertically — the tail of one can sit underneath the body of the next. A line of Urdu text is not a horizontal strip you can crop. Line segmentation, which is trivial for Latin script, is itself a research problem here.

Then there are the dots. Several Urdu letters are identical in body and differ only in the number and placement of dots above or below. A speck of dust, a printing flaw or a compression artefact is not a cosmetic problem; it changes the letter, which changes the word. Diacritics stack in the same vertical space, so the model has to attribute each mark to the correct base letter along a diagonal.

Finally, training data. English OCR models have been trained on enormous, carefully labelled corpora for decades. Labelled Nastaliq page images are comparatively scarce, and much of what exists is modern printing rather than the older typesetting and lithography that historical books are actually in.

This is why the working approach for Urdu is not character segmentation at all. It is whole-line recognition — a model reads an entire line image and outputs a sequence of characters, never committing to where one letter ends and the next begins.

Preparing scans, which matters more than the software

For Urdu, input quality has an unusually large effect on output quality, because the failure mode is losing dots and dots are most of the information. These are worth doing properly:

  • Scan at 300 dpi minimum, 400 to 600 for small type or old lithographed text. Below 300 the dots start merging into their base letters and no model recovers them.
  • Get the page flat. A curved page near the spine distorts the diagonal baseline and is one of the most common causes of a page that recognises badly while its neighbours are fine. A flatbed scanner beats a phone; if you must use a phone, press the book open and shoot straight down.
  • Light the page evenly. A shadow gradient across the page makes a thresholding step misjudge one half of it. Diffuse light from two sides beats one bright lamp.
  • Straighten before you submit. A page rotated even two or three degrees measurably hurts line detection given the diagonal baseline. Most scanning apps will deskew automatically; check that they did.
  • Prefer greyscale over aggressive black-and-white conversion. Hard thresholding is what erases faint dots. Let the recogniser see the grey.
  • Crop out the facing page, fingers and the ruler you used to hold the book down. Anything that is not the page is something the layout stage has to guess about.
  • Keep pages in order and named in order. Reassembling a book from out-of-order output is a bigger job than the scanning was.

What accuracy to expect

Be realistic and plan for proofreading. Clean, modern, well-printed Urdu at 300 dpi recognises well enough that reading through and correcting is much faster than retyping. Older lithographed books, handwritten manuscripts, poetry with dense diacritics, and anything with foxing or bleed-through are substantially harder and can require heavy correction.

Certain error classes recur and are worth learning to spot: dot-count confusions between otherwise identical letters, missing or duplicated whitespace inside compound words, and the wrong Unicode character for visually similar forms — particularly the Arabic versus Urdu variants of the same letter, which look right on screen and break every search you later run.

Poetry is a special case. Line breaks and the alignment of hemistichs carry meaning, and OCR output routinely flattens that structure. If you are digitising verse, budget time for restoring the layout by hand.

Proofreading efficiently

Do not read the output on its own. Read it beside the page image, one page at a time. Errors are invisible in isolation because a wrong Urdu word is still a plausible Urdu word.

Fix the systematic errors first. If a particular letter is being misrecognised the same way throughout, one find-and-replace across the whole book beats a thousand individual corrections. Run those global fixes before you start reading line by line, or you will fix the same thing repeatedly.

Search for the characters that should not be there — Arabic-form letters in an Urdu text, Latin digits where you expect Urdu ones, doubled spaces. Each search finds a whole class of error at once.

And normalise the Unicode at the end. Deciding on one canonical form for each letter is what makes the finished text searchable, which is the entire reason for doing the digitisation.

Why any of this is worth doing

A book that exists only as paper is a book that cannot be searched, quoted accurately, indexed, translated by machine, read aloud by a screen reader, or preserved against the loss of the single copy. Urdu has an enormous body of poetry, prose, scholarship and periodical writing in exactly that condition — physically present, digitally absent.

Digitisation is also cumulative in a way most work is not. Every correctly recognised and proofread page is a page that can become training data for a better recogniser, which makes the next book cheaper to digitise. The reason Latin OCR is solved is that people did this work for decades.

RafayGen's Urdu OCR

RafayGen's OCR tool was built for Urdu specifically rather than adapted from a Latin pipeline. It reads scanned pages, photographs of text and image-only PDFs, handles whole books page by page while keeping the reading order, and returns both searchable text you can copy and a rebuilt PDF with a real text layer under the page image — so the scan still looks like the original but is searchable.

It began as a project to digitise Urdu literature, which is why it is tuned for books rather than for forms and receipts. Everything in this article applies to it: scan quality dominates the result, and the output needs proofreading before you rely on it.

Try RafayGen free →