If you open a PDF and can't select the text with your mouse, it's a scan: every page is a picture. To the computer there are no letters, only coloured dots. Converting it to Word as is would give you one image per page, which you can't edit.
Getting the text out takes OCR (optical character recognition): a program that looks at the picture and works out which letters are there and where. Here's what our converter does with a scan, and what you can expect from the result.
How we know it's a scan
A page counts as scanned if it has no text and its images cover at least half of it. The other pages in the same PDF are converted the normal way: a document can mix text pages and scanned pages, and each gets what it needs.
What we do before reading
Handing the picture straight to the OCR engine (we use Tesseract, free and battle-tested) works worse than you'd think. So we prepare the page first:
- It's rendered at 300 dots per inch, the resolution OCR reads best.
- Photos are masked. OCR sees letters everywhere: in a photo of a person it "read" things like eS tS. That fake text covered the photo and the converter ended up throwing the photo away. Now we detect photo areas by their grey tones and the OCR skips them: the photo stays an image.
- Long lines are removed (table borders, form lines). On top of a line, the OCR skipped the header row of tables. The lines are erased from the copy the OCR reads and then drawn back as real lines. That way the converter recognises the table and can rebuild it as a Word table.
The OCR then returns each word with its box. We place that text, invisible, over the page image in its exact spot. From there the page is converted like any PDF with text: paragraphs, columns, tables, with words where they were.
What works well
- Clean printed text: letters, contracts, reports, photocopied articles.
- Tables with borders, thanks to the redrawn lines.
- Printed forms with their fields and lines.
- Spanish and English, the languages the server reads, accents included.
What not to expect
- Handwriting. OCR is built for print. Handwriting comes out badly at best.
- Phone photos that are tilted, in perspective or shadowed. A slightly skewed page reads fine; a photo taken over the desk, much worse.
- The original font. OCR knows which letter it is, not which typeface. The size comes from what each line measures, but the font will be a standard one.
- Fax quality or very low resolution. If you have to squint to read it, so does the OCR.
- Other languages. French or German text reads almost right, but letters specific to those languages may come out wrong.
- Stray errors. Even with a good scan, some word will be misread (an l for a 1, rn for m). If the document matters, proofread it.
And a matter of time: OCR takes 5 to 10 seconds per page, and each conversion has a time limit. In very long scanned documents, pages there's no time for stay as images, and the result tells you so.
How to scan for better results
- 300 dpi on the scanner. More doesn't help much; less shows.
- Straight, whole page, no fingers or black edges.
- Greyscale for text; colour if photos matter. The "pure black and white" mode of some scanners eats thin strokes.
- On a phone, a scanning app that straightens the page beats the normal camera.
Do you really want Word?
Sometimes what you need isn't to edit but to search and copy text from a scan. There's a better option for that: OCR PDF. It keeps every page exactly as it was, with the original image, and lays the OCR text invisibly on top. It looks like the original and you can search, select and copy. If you need to change the content, then yes: PDF to Word.
Comments or ideas? Message me on LinkedIn. LinkedIn →