Text search and extraction in Blazor PDF Viewer
10 Jun 20261 minute to read
The Blazor PDF Viewer provides an integrated text search experience that supports both interactive UI search and programmatic searches. Enable the feature by setting EnableTextSearch as needed. To give more low-level information about text, methods like SearchTextAsync can be used.
The text search functionality allows you to retrieve and locate content within PDF documents with case-sensitive or case-insensitive matching, enabling integration with search analytics and downstream processing workflows.
Key capabilities
- Text search UI: real‑time search from the toolbar, match‑case option, and search navigation controls.
-
Text search programmatic APIs: mirror UI behavior with
SearchTextAsync,SearchNextAsync,SearchPreviousAsync, andCancelTextSearchAsync. -
Text search events: respond to
OnTextSearchStart,OnTextSearchHighlight, andOnTextSearchCompletefor UI sync, analytics, and custom overlays.
When to use which API
- Use the toolbar/search panel for typical interactive searches and navigation.
- Use
SearchTextAsync/SearchNextAsync/SearchPreviousAsyncwhen driving search programmatically but keeping behavior consistent with the UI. - Use
OnTextSearchStart,OnTextSearchHighlight, andOnTextSearchCompleteevents when you need to respond to search lifecycle changes for UI updates or logging.