AddTextMarkupFromSearchHits

Annotations and hotspot links

Description

Adds one text markup annotation per rectangle in Hits, turning any hit array returned by SearchText, SearchTextEach, SearchTextBatch or GetTextInAreaEx straight into markup annotations without a manual loop over AddTextMarkupAnnotation

For each hit, a rectangle whose Page is outside the document's page range or whose Right/Bottom does not exceed Left/Top is skipped. Every surviving rectangle temporarily selects the hit's page before adding the annotation; the page that was selected when the call started is always restored before returning, even for hits spanning several pages

Syntax

Delphi

Function TPDFlib.AddTextMarkupFromSearchHits(MarkupType: Integer; Const Hits: Array Of TPDFlibSearchHit): Integer;

Parameters

MarkupType1 = Highlight, 2 = Underline, 3 = Squiggly, 4 = StrikeOut
HitsSearch hits to turn into annotations, typically produced by SearchText, SearchTextEach, SearchTextBatch or GetTextInAreaEx

Return values

The number of annotations actually created. Hits with an out-of-range page or a degenerate rectangle are skipped and do not count. Returns 0 without changing the current page selection when MarkupType is outside 1–4, no document is selected, or Hits is empty

Remarks

Use HighlightTextSearchHits instead when the hits to mark up are the ones already retained by an active BeginTextSearch session. Set SearchContextChars before searching to also capture surrounding text on each hit for inspection or logging before marking it up

See also

AddTextMarkupAnnotation, HighlightTextSearchHits, SearchText, SearchTextEach, SearchTextBatch, TPDFlibSearchHit