PdfOcr class
Namespace: PdfNetStack.Ocr
Assembly: PdfNetStack.Ocr.dll
Package: PdfNetStack.Ocr
Makes scanned PDFs searchable: finds the image that is each page’s scan, reads it with an IOcrEngine, and lays the words over it as invisible text, so the page looks the same but selects, copies and searches.
public sealed class PdfOcrInheritance
Examples
Section titled “Examples”using var engine = OnnxOcrEngine.Load();
PdfDocument doc = PdfDocument.Open("scan.pdf");
PdfOcrReport report = new PdfOcr(engine).MakeSearchable(doc);
doc.Save("scan-searchable.pdf");
Constructors
Section titled “Constructors”PdfOcr(IOcrEngine, PdfOcrOptions?)
Section titled “ PdfOcr(IOcrEngine, PdfOcrOptions?)”Uses engine; the caller keeps ownership and disposes it.
public PdfOcr(IOcrEngine engine, PdfOcrOptions? options = null)Parameters
Section titled “Parameters”engine IOcrEngine
The recognizer.
options PdfOcrOptions?
Languages, limits and skipping; defaults when null.
Methods
Section titled “Methods”MakeSearchable(PdfDocument, CancellationToken)
Section titled “ MakeSearchable(PdfDocument, CancellationToken)”Reads every scanned page and adds invisible text to it.
public PdfOcrReport MakeSearchable(PdfDocument document, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”document PdfDocument
The document, changed in place; save it afterwards.
cancellationToken CancellationToken
Stops between pages and lines.
Returns
Section titled “Returns”Recognize(PdfDocument, CancellationToken)
Section titled “ Recognize(PdfDocument, CancellationToken)”Reads every scanned page without changing the document.
public PdfOcrReport Recognize(PdfDocument document, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”document PdfDocument
The document.
cancellationToken CancellationToken
Stops between pages and lines.