How can I help you?
Text search and extraction in Angular PDF Viewer
17 Apr 20261 minute to read
The Angular PDF Viewer provides an integrated text search experience that supports both interactive UI search and programmatic searches. Enable the feature by importing TextSearch and injecting it into the viewer services and by setting enableTextSearch as needed. To give more low-level information about text, findText and findTextAsync methods can be used.
The extractText API can be used to retrieve plain text from pages or structured text items with their positional bounds, allowing you to index document content, perform precise programmatic highlighting, map search results to coordinates, and create custom overlays or annotations; it can return full-page text or itemized fragments with bounding rectangles for each extracted element, enabling integration with search, analytics, and downstream processing workflows.
Key capabilities
- Text search UI: real‑time suggestions while typing, selectable suggestions from the popup, match‑case and “match any word” options, and search navigation controls.
-
Text search programmatic APIs: mirror UI behavior with
searchText,searchNext,searchPrevious, andcancelTextSearch; query match locations withfindTextandfindTextAsyncwhich return bounding rectangles for matches. -
Text extraction: use
extractTextto retrieve page text and, optionally, positional bounds for extracted items (useful for indexing, custom highlighting, and annotations). -
Text search events: respond to
textSearchStart,textSearchHighlight, andtextSearchCompletefor UI sync, analytics, and custom overlays.
When to use which API
- Use the toolbar/search panel for typical interactive searches and navigation.
- Use
searchText/searchNext/searchPreviouswhen driving search programmatically but keeping behavior consistent with the UI. - Use
findText/findTextAsyncwhen you need match coordinates (bounding rectangles) for a page or the whole document. - Use
extractTextwhen you need plain page text or structured text items with bounds.