GemBox.PdfViewer
  • Overview
  • Examples
  • Free version
  • Support
  • Pricelist

    Show / Hide Table of Contents

    Search Class

    Namespace:
    @gembox/pdfviewer
    Assembly:
    @gembox/pdfviewer

    Provides search functionality for finding text within PDF documents.

    • TypeScript
    export declare class Search implements EventElement<SearchEventMap>
    Inheritance:
    Search
    Implements
    EventElement
    Remarks

    The Search class enables users to search for specific text within a PDF document, navigate between search results, and receive notifications about search progress through events. It integrates with the underlying PDF.js library to perform the actual search operations.

    Properties

    query

    Gets the current search query text.

    • TypeScript
    get query(): string;
    Remarks

    This property returns the text that is currently being searched for in the document.

    currentMatch

    Gets the current position in the search results.

    • TypeScript
    get currentMatch(): number;
    Remarks

    This property returns the index of the currently selected search result (zero-based).

    matchCount

    Gets the total number of search matches found.

    • TypeScript
    get matchCount(): number;
    Remarks

    This property returns the total count of all matches for the current search query.

    Methods

    addEventListener(K, (event: SearchEventMap[K]) => void)

    Adds an event listener for the specified event type.

    • TypeScript
    addEventListener<K extends keyof SearchEventMap>(type: K, listener: (event: SearchEventMap[K]) => void): void;
    Parameters
    type

    The event type/name to listen for.

    listener

    The callback function that will be invoked when the event is emitted.

    search(string | undefined)

    Starts a new search operation with the specified query.

    • TypeScript
    search(query: string | undefined): void;
    Parameters
    query

    The text to search for in the document. If undefined or empty, any active search is cancelled and cleared.

    Remarks

    This method initiates a search for the specified query text. It emits a SearchStartingEvent before performing the search, allowing listeners to cancel the operation if needed. If the query is undefined or empty, it cancels any active search and clears the search state.

    nextMatch

    Navigates to the next search match in the document.

    • TypeScript
    nextMatch(): void;
    Remarks

    This method moves the selection to the next occurrence of the current search query. If there are no more matches after the current position, this method has no effect.

    previousMatch

    Navigates to the previous search match in the document.

    • TypeScript
    previousMatch(): void;
    Remarks

    This method moves the selection to the previous occurrence of the current search query. If there are no matches before the current position, this method has no effect.

    clear

    Ends the current search operation and clears all search state.

    • TypeScript
    clear(): void;
    Remarks

    This method stops any active search, clears the query text, resets the match counter, and hides the search UI elements. It should be called when search is no longer needed.

    Implements

    EventElement
    Back to top

    Facebook • Twitter • LinkedIn

    © GemBox Ltd. — All rights reserved.