OfficeIMO.Pdf.Ocr 3.4.0

Prefix Reserved
dotnet add package OfficeIMO.Pdf.Ocr --version 3.4.0
                    
NuGet\Install-Package OfficeIMO.Pdf.Ocr -Version 3.4.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfficeIMO.Pdf.Ocr" Version="3.4.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OfficeIMO.Pdf.Ocr" Version="3.4.0" />
                    
Directory.Packages.props
<PackageReference Include="OfficeIMO.Pdf.Ocr" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OfficeIMO.Pdf.Ocr --version 3.4.0
                    
#r "nuget: OfficeIMO.Pdf.Ocr, 3.4.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OfficeIMO.Pdf.Ocr@3.4.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OfficeIMO.Pdf.Ocr&version=3.4.0
                    
Install as a Cake Addin
#tool nuget:?package=OfficeIMO.Pdf.Ocr&version=3.4.0
                    
Install as a Cake Tool

OfficeIMO.Pdf.Ocr - OCR and searchable PDF integration

nuget version

OfficeIMO.Pdf.Ocr connects any OfficeIMO.Ocr.IOcrEngine to first-party PDF page rendering, native-text overlap filtering, logical reconstruction, and searchable PDF output. OCR is optional and is not part of the base OfficeIMO.Pdf dependency graph.

Install

Install the PDF integration and one provider. For Tesseract:

dotnet add package OfficeIMO.Pdf.Ocr
dotnet add package OfficeIMO.Ocr.Tesseract

Tesseract itself remains a separately installed host dependency. A custom or hosted provider only needs the OfficeIMO.Ocr contract.

Read scanned and mixed PDFs

using OfficeIMO.Ocr.Tesseract;
using OfficeIMO.Pdf;
using OfficeIMO.Pdf.Ocr;

var engine = TesseractOcrEngine.CreateDefault();
PdfDocument pdf = PdfDocument.Load("mixed-report.pdf");

PdfOcrMergeResult result = await pdf.ReadWithOcrAsync(
    engine,
    new PdfOcrMergeOptions {
        Language = "eng+pol",
        Dpi = 180,
        MinimumConfidence = 0.75,
        ReadOptions = new PdfReadOptions {
            LayoutOptions = new PdfTextLayoutOptions {
                ReadingDirection = PdfReadingDirection.Auto
            }
        }
    });

Console.WriteLine(result.Document.Text);
Console.WriteLine($"Accepted OCR words: {result.AcceptedWordCount}");

Every selected page is rendered to a bounded raster request. Pixel, point, and normalized provider coordinates are projected into the page's cropped and rotated visual point space. Low-confidence spans and spans overlapping native text are rejected before OCR evidence enters the same language-neutral reading-order, region, list, paragraph, heading, and table pipeline as native positioned text.

NativeDocument retains the native-only parse. Document is the canonical native-plus-OCR parse and can be passed directly to the existing PDF-to-Word, Excel, PowerPoint, HTML, RTF, or OpenDocument adapters. Page results retain accepted words, provider/model/language evidence, rejections, and diagnostics.

Discover scanned redaction candidates

Use the same OCR geometry and native-overlap owner to map literal or bounded-regex matches into PDF user-space areas:

var search = new PdfRedactionSearchOptions()
    .AddLiteral("Account Secret")
    .AddRegex(@"\b\d{3}-\d{2}-\d{4}\b");

PdfOcrRedactionSearchResult candidates = await pdf
    .SearchRedactionCandidatesWithOcrAsync(engine, search);

foreach (PdfOcrRedactionCandidate candidate in candidates.Candidates) {
    Console.WriteLine($"Page {candidate.Area.PageNumber}: {candidate.Criterion}, confidence {candidate.MinimumConfidence:0.00}");
}

Candidate results intentionally omit recognized matched text. They retain the criterion index, geometry, minimum confidence, and provider/model/language evidence needed by a review workflow. Literal and regex search is isolated to provider-declared lines, with bounded geometric line inference only when hierarchy identifiers are unavailable, so candidates are not assembled across unrelated lines or columns. OfficeIMO.Workflows can combine these candidates with native matches, persist source-bound decisions, re-run the same provider after destructive application, and publish privacy-safe evidence.

Add a searchable text layer

PdfSearchableOcrResult searchable = await pdf.MakeSearchableAsync(engine);
await searchable.Document.SaveAsync("mixed-report-searchable.pdf");

Console.WriteLine($"Modified pages: {string.Join(", ", searchable.ModifiedPages)}");
Console.WriteLine($"Added words: {searchable.AddedWordCount}");

Only pages with accepted OCR words are rewritten. The invisible text layer follows the canonical semantic order, while the returned OCR result records exactly what was added. Signed or otherwise rewrite-sensitive documents remain subject to the base PDF mutation and preservation rules.

PdfOcrMergeOptions bounds provider-call duration, rendered pixels, selected pages, inspected spans, accepted OCR words and characters, aggregate raw hierarchy identifiers, provider metadata and diagnostics, native-overlap comparisons, and merged text. Calls use one shared OcrEngineExecution per document, so identity and capabilities are stable across pages and the same non-concurrent engine instance cannot overlap across PDF, Reader, or a future integration. Language is provider configuration only; it is never used to infer captions, lists, paragraphs, tables, or continuations.

Targets and dependency footprint

  • Targets: netstandard2.0, net8.0, net10.0 (net472 is also included on Windows builds).
  • OfficeIMO dependencies: OfficeIMO.Ocr and OfficeIMO.Pdf.
  • Not dependencies: Reader, Tesseract, process execution, cloud SDKs, or native OCR runtimes.
  • License: MIT.

See the OfficeIMO.Pdf README for native reading and document operations.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on OfficeIMO.Pdf.Ocr:

Package Downloads
OfficeIMO.Workflows

Typed local document workflows that compose first-party OfficeIMO conversion, PDF, and provenance capabilities.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.4.0 0 9/6/2026