function ApplyOcrSearchLayer(
const Provider: IPdfOcrProvider;
const Options: TPdfOcrOptions;
out Report: TPdfOcrReport;
const CancellationToken: IPdfCancellationToken = nil): Boolean;
Requires the Small Business or Enterprise edition: add FPdfSmallBusiness to a uses clause (with Lib\SmallBusiness on the search path); otherwise the method raises EPdfSmallBusinessRequired
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 RejectedWordCount. RejectedWordCount counts invalid words (empty or over-long text, an out-of-range confidence, or a quad outside the image); words below MinConfidence are filtered and counted in neither, so DetectedWordCount minus the other two is the filtered countTPdfOcrOptions is the options record ApplyOcrSearchLayer receives; TPdfOcrOptions.Default starts from 300 DPI, a 0.5 confidence floor, an Arial invisible text layer font, SkipPagesWithText and ContinueOnError enabled, and the pixel, word, and per-word character budgets listed below
FirstPage 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
Since v3.275.0, cached Unicode fonts encode complete characters through their CID maps, including supplementary-plane characters; FontName must select a Unicode font whose cached cmap covers the requested text, such as an appropriate symbol font for supplementary symbols
Supplementary insertion requires the native custom CID font and charcode APIs; missing mappings or required APIs, NUL and unpaired UTF-16 units fail explicitly, and every new word on the failed or cancelled page is removed
Completed pages follow the existing page-level recovery policy; publish saved source bytes only after checking the overall report, then bind a new semantic review to those exact saved bytes before requesting tagged output
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;