C# OCR Library:
Add OCR to a .NET Application
For developers building in .NET, 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 C#
The Apryse OCR Module is a separately licensed add-on for the Apryse Server SDK. You can install the base SDK via NuGet: PDFNet for .NET Framework, PDFTron.NET.x64 (or PDFTron.NET.ARM for ARM64) for .NET 8/9. Call pdftron.PDFNet.Initialize() before any SDK method. Your trial key gives you full access to all the add-ons to the Server SDK.
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 post covers installing the OCR Module in a C# or .NET project, running OCR on a scanned PDF, and extracting the result as a searchable PDF or structured JSON/XML data. See Apryse OCR capabilities for the full capability set. Get a trial license key to use it yourself.
Installation: .NET Framework and .NET 8/9
The Apryse Server SDK easily installs via NuGet.
.NET Framework (4.5.1+):
In Visual Studio's NuGet Package Manager, search for and install PDFNet. This deploys both x86 and x64 builds via PDFNetLoader, which loads the correct one at runtime, so no manual reference juggling is needed for Any CPU projects. Prefer the manual path (download PDFNetDotNet4.zip, reference PDFNet.dll and PDFNetLoader.dll directly) only if your project needs a single fixed architecture without PDFNetLoader.
.NET 8/9:
Run dotnet add package PDFTron.NET.x64 (or PDFTron.NET.ARM for ARM64 targets). The manual alternative, downloading PDFNetC64.zip and referencing PDFNet.dll directly, remains available for build setups that can't take a NuGet dependency.
Docker and Linux Deployments
For Linux and containerized deployments, install the same NuGet package as any .NET 8/9 target (PDFTron.NET.x64, or PDFTron.NET.ARM on ARM64). Initialize PDFNet once at container startup, not per request, and terminate it on shutdown. The Default engine runs on CPU, no GPU is required. Docker doesn't tolerate the symlinked native library the SDK ships by default: copy libPDFNetC.so directly into /usr/lib/ in your Dockerfile, then either remove the symlink and rename the versioned .so to libPDFNetC.so, or point your .csproj at the versioned file directly. See Apryse's Docker FAQ for both approaches.
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 C#
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.
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.
Downstream uses include feeding extracted fields into an AI ingestion pipeline, populating a database, or validating form fields against expected values.
Apryse OCR vs. IronOCR and Tesseract.NET
Developers adding OCR functionality to a .NET application are probably also considering other solutions such as IronOCR and Tesseract. This brief comparison gives you a few things to consider. While IronOCR wraps Tesseract as its internal OCR engine, the Apryse OCR Module's Default engine is a distinct deep-learning engine, not a Tesseract wrapper.
While IronOCR does have a well-documented .NET API and built-in barcode reading, we think Apryse has the edge. With Apryse, a single OCR call produces both a searchable PDF and structured JSON/XML with position data, IronOCR's output requires additional code to get both formats from one document. Apryse also holds SOC 2 and ISO 27001 certifications, and uses flat licensing that does not compound per page at volume.
Tesseract.NET (the NuGet wrapper) is a free option for budget-constrained projects and simple document types, but it has no enterprise support or SLA, no SOC 2 or ISO 27001, and outputs text only, producing a searchable PDF or structured position data on top of that requires additional libraries and custom code.
Comparison based on publicly available information current as of 2026.
On-Premise and Offline OCR in C#
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.
