Java OCR Library:
Add OCR to a Java Application
For developers building in Java, the right OCR SDK lets you convert scanned PDFs and image files into searchable PDFs with selectable text layers, plus extraction to JSON or XML. Here's how to get it all done in your own infrastructure without any external dependencies.
What the Apryse OCR Module Does in Java
The Apryse OCR Module is a separately licensed add-on for the Apryse Server SDK. For Java, developers can install the OCR add-on through Maven (groupId com.pdftron, artifacts OCRModuleWindows or OCRModuleLinux) on Windows and Linux, or by extracting the module archive directly into your SDK directory on macOS. Call PDFNet.initialize() before any SDK method. Trial keys from dev.apryse.com include unlimited OCR Module access during evaluation. Please note that while Gradle is supported for the Server SDK install, we don't currently offer a documented Gradle install path for the OCR Module. Use Maven or manage dependencies manually.
Input formats include JPEG, PNG, TIFF, BMP, and image-based PDFs. Output is either a searchable PDF with a selectable text layer, or structured JSON or XML with text content and position data, from the same OCR operation.
This page covers installing the OCR Module in a Java project, running OCR on a scanned PDF, and getting the result back as a searchable PDF or as structured data. See Apryse OCR capabilities for the full capability set. Get a trial license key to use it yourself.
Installation: Maven and Archive Extraction
The Apryse Server SDK for Java installs via Maven (groupId com.pdftron) or a direct download of PDFNetJava.zip, and requires JDK v25 (LTS). The OCR Module is a separate download and a separate license from the base SDK.
Step 1:
Add the base SDK dependency to your pom.xml, or download PDFNetJava.zip and add it to your project's classpath.
Step 2:
Add the OCR Module dependency: on Windows, the OCRModuleWindows artifact (groupId com.pdftron); on Linux, OCRModuleLinux. On macOS, there is no Maven path for the OCR Module. Download the module archive from docs.apryse.com/core/guides/info/modules#ocr-module and extract it into your SDK directory.
Docker and Linux Deployments
For Java on Linux, use the PDFNetJava.zip base SDK build together with the OCRModuleLinux Maven artifact. Initialize PDFNet once at container startup, not per request. The V12 Default engine runs on CPU; no GPU is required. Set the native library path explicitly in your container's execution environment.
For the full self-hosted deployment architecture, see the self-hosted OCR deployment guide.
OCR a Scanned PDF to Searchable PDF
To make a searchable PDF by adding invisible text to an image based PDF such as a scanned document using OCR, use the following code snippet:
Visit Add searchable/selectable text to an image based PDF like a scanned document for a full code sample which shows how to use the Apryse OCR module on scanned documents in Java.
Extract OCR Output as JSON or XML in Java
The same OCR operation can output structured JSON or XML instead of, or alongside, the searchable PDF, with text content, bounding box coordinates per word, and page numbers. No second library is required.
Downstream uses include feeding extracted fields into an AI ingestion pipeline, populating a database, or validating form fields against expected values.
If you want to apply raw OCR output to the input document, you can either call OCRModule::ImageToPDF (if input file is an image) or OCROptions::ProcessPDF (for a PDF). However, it is likely that some post-processing will be beneficial, e.g., comparing results against white/black lists. To this purpose, you can first extract text and corresponding metadata as either JSON or XML before re-applying processed results to the input document.
Apryse OCR vs. Tesseract and Alternatives
In addition to Apryse SDK, you may be considering Tesseract, the most popular open-source OCR engine, as well as other proprietary SDKs such as Aspose and Asprise OCR. Here's our comparison of these for your consideration.
Asprise OCR is a proprietary Java OCR library commonly recommended alongside it. Both are legitimate starting points; the tradeoffs differ by what you need the output to do.
The Apryse OCR Module's default engine (V12) is a deep-learning neural-network engine, run entirely on your own infrastructure with no cloud API call during processing. From one operation, it produces both a searchable PDF with a selectable text layer and structured JSON or XML with bounding box data, so a project that needs both outputs does not need a second library or a custom implementation to get there.
Tesseract can be accessed in Java through the tess4j JNA bindings. Tesseract/tess4j is free and widely used, but tess4j output is text only; producing a searchable PDF or structured position data on top of it requires additional code and libraries.
Aspose offers format breadth (Aspose.Total spans 28 products across .NET, Java, Python, and C++) and OCR integrated into its PDF library with transparent published pricing. It is headless only, with no viewer or annotation layer, and its cloud and MCP integration paths route documents through Aspose's cloud infrastructure rather than staying on your own.
Take a look:
Comparison based on publicly available information current as of 2026.
On-Premise and Offline OCR in Java
If you're dealing with data residency requirements, air-gapped environments, or a policy against sending documents to a third party, the Apryse OCR Module runs entirely on infrastructure you control, with no network call during processing. This makes it usable in regulated or disconnected en In comparison, cloud services such as Azure Computer Vision or Google Document AI require an active connection to a vendor's infrastructure and are not suitable for offline or air-gapped use. When evaluating open-source OCR SDKs, be sure to check if external API calls are used in processing.
