function ApplyOcrSearchLayer(
const Provider: IPdfOcrProvider;
const Options: TPdfOcrOptions;
out Report: TPdfOcrReport;
const CancellationToken: IPdfCancellationToken = nil): Boolean;
The library renders each selected page through PDFium and passes a compact top-down popfBgra32 image to IPdfOcrProvider.RecognizePage
The provider returns TPdfOcrWord values whose Quad coordinates use pixel units with the origin at the image top left
Text confidence must be in the range 0 through 1 and quadrilateral points must remain inside the supplied image
FPDF_DeviceToPage mapping preserves page boxes and intrinsic rotationFPDF_TEXTRENDERMODE_INVISIBLETPdfOcrReport totals ProcessedPageCount, FailedPageCount, DetectedWordCount, InsertedWordCount, RejectedWordCount, and TotalRenderedPixels, while each TPdfOcrPageReport entry adds per-page ImageWidth, ImageHeight, DetectedWordCount, InsertedWordCount, and RejectedWordCountFirstPage and LastPage select an inclusive range, while zero selects the document boundary
SkipPagesWithText avoids duplicating an existing searchable layer and ContinueOnError controls page-level recovery
Budgets enforced fail-closed before page mutation cover MaxPixelsPerPage and MaxTotalPixels pixels, MaxWordsPerPage and MaxTotalWords words, MaxWordCharacters characters per word, plus confidence and DPI
var
Options: TPdfOcrOptions;
Report: TPdfOcrReport;
begin
Options := TPdfOcrOptions.Default;
Options.Dpi := 300;
Options.MinConfidence := 0.75;
if Pdf1.ApplyOcrSearchLayer(OcrProvider, Options, Report) then
Pdf1.SaveAs('searchable.pdf');
end;