OCRPageEx

OCR, rendering, document editing

Description

Checks the existing-text policy, renders one page to PNG when needed, invokes the selected OCR provider, and applies the result as an owned invisible text layer

Syntax

Delphi

Function TPDFlib.OCRPageEx(Page: Integer; DPI: Double; Const Language,
  FontName: WideString; MinConfidence: Double; Options: Integer): Integer;

ActiveX

Function PDFlib::OCRPageEx(Page As Long, DPI As Double, Language As String,
  FontName As String, MinConfidence As Double, Options As Long) As Long

DLL

int DLOCRPageEx(int InstanceID, int Page, double DPI, const wchar_t* Language,
  const wchar_t* FontName, double MinConfidence, int Options);
int DLOCRPageExA(int InstanceID, int Page, double DPI, const char* Language,
  const char* FontName, double MinConfidence, int Options);

Parameters

PageThe one-based target page
DPIThe finite positive raster resolution supplied to the provider
LanguageA provider-defined language hint; the configured Tesseract provider uses trained-data names such as eng
FontNameAn embeddable TrueType font or an empty string for fallback selection
MinConfidenceThe inclusive word-confidence threshold from 0 through 1
OptionsThe bitwise layer policies defined by ApplyOCRTextLayerEx; zero appends, 1 skips existing non-owned text, and 2 replaces owned OCR layers

Return values

1The result was applied, the page was skipped, or no word met the threshold
0Rendering, provider execution, result validation, layer writing, or cancellation prevented completion

Remarks

Use ConfigureTesseractOCR for the supplied engine adapter or assign an application-owned OnOCRPage callback

The existing-text check runs before rendering and provider execution, so a skipped page does not require an OCR engine

Only owned old OCR streams are ignored by that check; a foreign invisible text layer or hidden text in an invoked Form XObject still counts as existing text

Enable orientation detection explicitly for scans that need a verified quarter-turn correction; low orientation confidence fails without changing the OCR layer

Read GetOCRDiagnosticsJSON for the layer action and configured engine's latest recognition and orientation reports

See also

OCRPage, OCRDocumentEx, ApplyOCRTextLayerEx, ConfigureTesseractOCR, LastOCRError