I have confirmed that the OCR output itself contains Nozzle. Ho 12, so the issue appears to happen during OCR rather than during the Regex extraction.
My question: What is the best way to handle this in UiPath? Should I change the Tesseract OCR settings, preprocess the PDF/image, use another free OCR engine available in Community Edition, or use a different Regex/approach?
I want the bot to reliably extract the actual nozzle number without hardcoding a correction such as changing 12 to 2.
Any suggestions or best practices would be appreciated.
My best advice would be to use some sort of AI if you’re struggling to get consistency. GenerativeAI activities are great and pretty accurate. Or if you’re dealing with a lot of receipts, trying using IXP (Document Understanding) and train a model to read everything off each receipt. But this will consume AI/Platform units depending on which Community plan you’re on. Still worth trying.
I think the issue is with the OCR itself, not the Regex. Since Tesseract is reading Nozzle. No : 2 as Nozzle. Ho 12, the Regex is just extracting the wrong value from the OCR result.
I’d try improving the image quality first, like cropping the nozzle section and increasing the resolution/contrast before running Tesseract.
You can also test another OCR engine, such as Microsoft OCR, and compare the results. I wouldn’t hardcode 12 to 2, because that may fail with other receipts.
Read PDF with OCR with Tesseract OCR will work. Try changing the properties of Tesseract OCR.
Scale: Start from 0 increasing it by 0.5 until 5. In any one of the point, you will be getting the exact text.
Profile: You will have 4 options over there for every scale try changing by 4 options.
If Tesseract OCR doesn’t work for your exact extraction, try using Omni page OCR by downloading UiPath.OmniPage.Activities. This may work for you.
Try Microsoft OCR or OmniPage OCR instead of Tesseract.
They generally handle receipts and scanned documents better than Tesseract.
Improve image quality before OCR
Convert PDF to a higher resolution image.
Apply image preprocessing such as grayscale, contrast enhancement, or noise removal.
Better image quality usually improves OCR accuracy significantly.
Use anchor-based extraction
After OCR, find the line containing "Nozzle" and extract the value immediately after ":".
This is often more reliable than searching the entire text.
Validate against business rules
If nozzle numbers are typically single digits , add a validation step.
When OCR returns suspicious values like 12 while the receipt layout suggests a single nozzle number, flag it for review instead of hardcoding corrections.
Regex is fine
Your current Regex is not causing the error.
The root cause is the OCR output itself. Focus on improving OCR quality rather than changing the Regex.