Scans, Photos and Messy PDFs: Preparing Customer Documents Before AI Reads Them
Customers send documents in every format. Here is how to clean up scans, photos, handwriting and broken PDFs so your AI reads them reliably.

Most AI projects built on documents get tested on clean files: a tidy PDF exported from accounting software, or a sample contract someone saved from Word. Then the system goes live and customers start sending what they actually have. That means a phone photo of an invoice on a kitchen table, a fax scanned three times, a form filled in by hand in blue biro, or a 40-page PDF where every page is an image.
The model rarely fails at the reading. It fails because nobody prepared what it reads. If you plan for that preparation step from the start, document AI becomes dependable. If you skip it, you get a system that works in the demo and quietly makes mistakes in production.
Sort before you read
The first job is to work out what has arrived. A PDF can hold real, selectable text, or it can be a stack of pictures wrapped in a PDF file. A single upload can contain an invoice, a delivery note and a signed cover letter, all in one file.
Before anything reaches the model, a sorting step should answer three questions: is there real text, or only images? What kind of document is each page? Does this file hold one document or several? Splitting a mixed upload into separate documents makes everything after it more accurate, and it costs very little to build.
Fix the image, then extract the text
For scans and photos, the quality of the image sets a ceiling on everything that follows. Most of the work happens here, and it is mechanical:
- Straighten and crop. Phone photos come in at an angle with a table, a thumb or a second page in the frame. Correcting the perspective and cropping to the page edges removes most errors on their own.
- Fix contrast and remove shadows. Grey fax backgrounds and a shadow from someone's phone hide digits. Cleaning them up turns faint characters into legible ones.
- Rotate correctly. Pages scanned upside down or sideways are more common than you would expect, especially in long batches.
- Check resolution. Below a certain point no software can recover small print. Detect it and ask the customer for a better copy, rather than guessing.
- Keep the original. Always store the untouched file next to the cleaned version. When a figure is disputed, you need to show what the customer actually sent.
Once the image is clean, text extraction (OCR, or a vision model reading the page directly) can do its job. Modern vision models handle imperfect images far better than older OCR did. They still read a straight, high-contrast page more accurately than a skewed, shadowed one, and the difference shows up in exactly the fields you care about: amounts, dates, account numbers.
Treat handwriting as its own case
Handwriting is where expectations need the most care. Current models read neat block capitals well, cursive less well, and badly scribbled notes poorly. They also tend to produce a confident answer even when the ink is ambiguous, and that is the real risk.
The practical answer is to decide in advance which handwritten fields matter. A name or a free-text comment can tolerate small errors. A handwritten amount, a date of birth or a policy number cannot. For those, require the system to report how confident it is, and send anything below your threshold to a person. A five-second human check on one field costs far less than a wrong payment.
Messy PDFs deserve suspicion too
Digital PDFs are not automatically clean. Tables lose their structure when the text comes out, so a column of prices ends up attached to the wrong product. Some PDFs contain hidden text layers that do not match what is visible on the page. Password-protected and corrupted files fail outright.
Where a document carries tables that matter, such as statements, price lists or bills of materials, render the page as an image and let the model read the layout as a person would, rather than relying on the raw text alone. Then check the totals. If the line items do not add up to the stated total, something went wrong in reading, and the system should say so.
Build the checks into the flow
The most reliable document systems do not trust a single pass. They validate what they extract against things that must be true: dates fall in a plausible range, tax numbers match their format, totals reconcile, and the customer name matches the account it came in on. Each failed check is a cheap, specific signal that a person should look.
Measure this from day one. Track how many documents go through untouched, how many need a human, and why. That tells you whether to improve the image cleanup, adjust thresholds, or ask customers for better input at the point of upload, which is often the cheapest fix of all.
This preparation layer is unglamorous work, and it decides whether the project succeeds. It is the kind of heavy lifting we take on at Hercules A when we build document systems, because the model is only as good as the page it is given.