Table of Contents

Class SearchHighlightOptions

Namespace
LMKit.Document.Search
Assembly
LM-Kit.NET.dll

Configuration for a search-and-highlight operation performed by SearchHighlightEngine. Combines search mode selection, text normalization, per-mode search parameters, highlight appearance, and page range filtering into a single options object.

public sealed class SearchHighlightOptions
Inheritance
SearchHighlightOptions
Inherited Members

Examples

Example 1: Exact text search with case sensitivity and whole-word matching.

using LMKit.Document.Search;

var options = new SearchHighlightOptions { SearchMode = SearchMode.Text, CaseSensitive = true, WholeWord = true, MaxResults = 50, ContextChars = 80, PageRange = "1-10" };

SearchHighlightResult result = await SearchHighlightEngine.HighlightAsync( "contract.pdf", "Confidential", options);

File.WriteAllBytes("contract_highlighted.pdf", result.OutputData); Console.WriteLine($"Found {result.TotalMatches} case-sensitive whole-word matches.");

Example 2: Regex search for email addresses on specific pages.

using LMKit.Document.Search;

var options = new SearchHighlightOptions { SearchMode = SearchMode.Regex, RegexIgnoreCase = true, MaxResults = 200, ContextChars = 60, PageRange = "1,3,5-8" };

SearchHighlightResult result = await SearchHighlightEngine.HighlightAsync( "report.pdf", @"[\w.+-]+@[\w-]+\.[\w.]+", options);

File.WriteAllBytes("report_emails.pdf", result.OutputData); Console.WriteLine($"Highlighted {result.TotalMatches} email addresses.");

Example 3: Fuzzy search with custom green highlight appearance.

using LMKit.Document.Search;
using LMKit.Graphics.Primitives;

var options = new SearchHighlightOptions { SearchMode = SearchMode.Fuzzy, MaxEditDistance = 3, MinScore = 0.6, TokenAware = true, Appearance = new HighlightAppearance { Color = new Color32(0, 255, 0, 100), BorderWidth = 1.5f } };

SearchHighlightResult result = await SearchHighlightEngine.HighlightAsync( "scanned_document.pdf", "accomodation", options);

File.WriteAllBytes("fuzzy_results.pdf", result.OutputData); foreach (TextMatch match in result.Matches) { Console.WriteLine($"Page {match.PageIndex + 1}: "{match.Text}" (score: {match.Score:F2})"); }

Properties

Appearance

Gets or sets the visual appearance of search result highlights.

CaseSensitive

Whether the text search should be case-sensitive. Only applies when SearchMode is Text.

ContextChars

Number of characters of surrounding context to include in each match snippet. Clamped to the range [0, 1000].

MaxEditDistance

Maximum Damerau-Levenshtein edit distance permitted for fuzzy matching. Clamped to the range [1, 10]. Only applies when SearchMode is Fuzzy.

MaxResults

Maximum number of matches to return across all pages.

MinScore

Minimum normalized fuzzy score in the range [0..1]. Only applies when SearchMode is Fuzzy.

Normalization

Gets or sets the text normalization options applied before searching. Controls whitespace collapsing, diacritics removal, punctuation/symbol stripping, and custom character filtering.

PageRange

Optional page range string using 1-based page numbers (for example: "1-5", "1,3,7-9"). When null or empty, all pages are searched.

RegexIgnoreCase

When true, the regex pattern ignores case. Only applies when SearchMode is Regex.

RenderZoom

Zoom factor when rendering image output. Only applies to image-based documents. Clamped to the range [0.25, 4.0].

SearchMode

Gets or sets the type of search to perform.

TokenAware

When true, discounts whitespace substitution costs in fuzzy matching. Only applies when SearchMode is Fuzzy.

WholeWord

When true, only matches bounded by non-word characters on both sides are returned. Only applies when SearchMode is Text.

Share