Isaac Maw
Technical Content Creator
Published January 16, 2025
Updated August 06, 2026
4 min
How to Build Optical Character Recognition (OCR) in Python
Isaac Maw
Technical Content Creator

Summary: If you know basic Python, you’re well on your way to getting OCR up and running to improve productivity in your business processes for forms, scanned documents, and images of text, for example. Check out this quick guide to learn how to install and use the Apryse OCR module for the Apryse Server SDK.
Python is a popular programming language, and it has been for many years. It’s versatile and beginner-friendly, and it’s commonly used for software testing, task automation, and data science applications, such as data analysis or visualization.
These use cases make it an ideal language to work with optical character recognition (OCR), because OCR is a tool for collecting data: it translates human-readable images of text to machine-readable text, and it’s useful for processing high volumes of documents, such as scanned pages of legal discovery, images of ID cards, or insurance claim forms. All of these examples can also benefit from a python programmer who knows how to build automated processes to process these documents.
The OCR SDK for Apryse is a great way to add OCR capabilities to your Python application.
So, let’s get started!
How to Set Up OCR on Server/Desktop in Python
To add OCR functionality in the Apryse Server SDK, you need to install the OCR add-on module. Find it for download in our documentation here.
Setup
The first step in setup before you can begin using OCR is to set up the location of the Lib directory under which the external add-ons are installed so that the SDK knows where to look for them. This is achieved using the PDFNet AddResourceSearchPath function. If a relative path is used, it’s based on the end-user executable.
PDFNet needs to be initialized with a license key before it is used, and should be terminated when you have finished with it. That has not been included here so that you can focus on the OCR specific code.
PDFNet.AddResourceSearchPath("../../../PDFNetC/Lib/") Note: do not specify the actual Windows/Barcode or Linux/Barcode directories, where the extension libraries are, but the parent "Lib" folder. This allows you to add a single resource search path for all installed modules.
For error handling purposes, it is generally advisable to test whether the module is available via the IsModuleAvailable function.
if not OCRModule.IsModuleAvailable():
pass # OCR Module unavailable If you have the module installed but the function still returns false, please double check that the correct path was used in AddResourceSearchPath earlier.
Using the OCR
Now you’re ready to use OCR. Here are some sample workflows in Python:
OCR on an Image
The OCR Module makes a searchable PDF by adding invisible text to an image.
doc = PDFDoc()
# Run OCR on the image without options
OCRModule.ImageToPDF(doc, image_path, None) OCR on a PDF file
Here’s how to use the OCR SDK to add invisible text to an image based pdf file, such as a scanned document:
Adjusting the Input Resolution
Sometimes, tweaking the input DPI can help produce better results. Here’s how:
opts.AddDPI(300) Keep your license key confidential
License keys are uniquely generated and strictly confidential. Don't publish or store them in any public location, including public GitHub repositories.
You can get a trial license key for testing purposes, but you will need a commercial license in a production environment.
Other Workflows
In addition to these, you can also use the OCR module to work with the raw OCR output and metadata, and more. Check out our OCR documentation for Python to learn more.
Which OCR Engine is best in Python?
Like any good "which is best" question, the boring answer is correct: it depends.
As part of the Summer 2026 Release, Apryse shipped a new AI-powered OCR engine in the Server SDK, now the default. It improves accuracy, expands language coverage, and keeps every document on your own infrastructure so nothing ever leaves your environment.
Need something else? Apryse also offers engines built for other use cases: faster processing, languages outside the default engine's coverage, or document types like magazine covers and CAD drawings that need specialized handling because of complex layouts or vector content.
In Closing
The best OCR for your use case depends on performance for your input documents, resolution, and other factors. Try testing different OCR engines with your input needs and see what performs best.
While OCR is a well-established technology, it relies on computers recognizing the strange glyphs we humans have developed over thousands of years, and even sometimes scratch onto paper using graphite. Tweaking the input resolution, scanning parameters and other funky configuration settings may be required to get you the best results.
In any case, if you know Python and you have are interested in other Apryse Server SDK functionality, the OCR module is an easy place to start.
Try it now to start improving your productivity with searchable PDFs and more today!


