Class PdfSearch
Provides text search operations for PDF documents.
public static class PdfSearch
- Inheritance
-
PdfSearch
- Inherited Members
Examples
Example 1: Search all pages for a keyword.
using LMKit.Document.Pdf;
PdfTextSearchResult result = await PdfSearch.FindTextAsync("contract.pdf", "liability");
Console.WriteLine($"Found {result.TotalMatches} matches across {result.ScannedPages} pages.");
foreach (var match in result.Matches)
{
Console.WriteLine($" Page {match.PageIndex + 1}: ...{match.Snippet}...");
}
Example 2: Case-sensitive search with page range and match limit.
using LMKit.Document.Pdf;
using LMKit.Document.Search;
var textOptions = new TextSearchOptions
{
Comparison = StringComparison.Ordinal,
WholeWord = true,
MaxResults = 50,
ContextChars = 80
};
PdfTextSearchResult result = await PdfSearch.FindTextAsync(
"report.pdf", "Revenue", pageRange: "1-10", textOptions: textOptions);
Console.WriteLine($"Case-sensitive matches: {result.TotalMatches}");
Methods
- FindText(string, string, string, TextSearchOptions, CancellationToken)
Searches text in a PDF file and returns matching regions with snippets.
- FindTextAsync(string, string, string, TextSearchOptions, CancellationToken)
Searches text in a PDF file and returns matching regions with snippets.