pdfrx_web
    Preparing search index...

    Class PdfTextSearcher

    Interactive full-text search over a document, with progressive per-page scanning and current-match tracking. Obtain one from PdfrxViewer.createTextSearcher; the owning viewer paints the match highlights (all matches plus the current match in a distinct color) and scrolls to matches as you navigate.

    const searcher = viewer.createTextSearcher();
    searcher.addListener(() => updateUi(searcher.currentIndex, searcher.matches.length));
    searcher.startTextSearch('invoice'); // debounced; highlights + jumps to the first match
    await searcher.goToNextMatch();
    Index
    • get searchingPageNumber(): number | null

      The 1-based page number currently being scanned, or null before a search starts. Reaches the last page once scanning completes.

      Returns number | null

    • Subscribes to search-state changes (new matches, current-match moves, progress). Fires on the same events that repaint the viewer highlights.

      Parameters

      • listener: () => void

        The callback to invoke when the value changes.

      Returns () => void

      An unsubscribe function.

    • Releases the searcher: cancels any pending search and drops listeners. Called automatically when the owning viewer creates a new searcher or is disposed. Like resetTextSearch but does not notify listeners.

      Returns void

    • The [start, end) slice of matches that belongs to a page (1-based), or null if the page has not been scanned yet. Used by the viewer to paint per-page highlights.

      Parameters

      • pageNumber: number

        The 1-based page number.

      Returns { end: number; start: number } | null

      The resolved or null.

    • Makes the next match current and scrolls it into view. From no selection, starts at the first match.

      Returns Promise<number>

      The new current index, or -1 if already at the last match.

    • Makes the previous match current and scrolls it into view. From no selection, wraps to the last match.

      Returns Promise<number>

      The new current index, or -1 if already at the first match.