OCRDocument

OCR, rendering, document editing

Description

Runs the OnOCRPage provider pipeline over a page range while retaining only one raster page at a time

Syntax

Delphi

Function TPDFlib.OCRDocument(Const PageRange: WideString; DPI: Double;
  Const Language, FontName: WideString; MinConfidence: Double): Integer;

Parameters

PageRangeA page-range expression such as 1-3,7, or an empty string for every page
DPIThe positive raster resolution sent to the provider
LanguageA provider-defined language hint
FontNameAn embeddable TrueType font name or path, or an empty string for fallback selection
MinConfidenceThe inclusive threshold from 0 through 1

Return values

The number of pages processed before completion, failure, or cancellation

A successful call returns the number of pages selected by PageRange

Remarks

This method calls OCRDocumentEx with options zero, preserving append behaviour on every selected page

Configure the optional supplied adapter with ConfigureTesseractOCR or carry on using an application-owned callback

Use OCRDocumentEx with options 3 to skip native or foreign hidden text whilst replacing owned-only OCR layers

GetOCRDiagnosticsJSON describes the last attempted page, whilst the integer return value counts processed pages

Each PNG is released after its callback and before the next page is rendered, so peak raster memory follows the largest page rather than the page count

Operation progress and cooperative cancellation use the normal PDF Library for Delphi progress lifecycle

See also

OCRPage, OnOCRPage, ApplyOCRTextLayer, LastOCRError