PrizmDoc® v14.3 Preview Release - Updated
PrizmDoc / API Reference / Viewer Control / Namespace: PCCViewer / Class: SearchRequest
In This Topic
    Class: SearchRequest
    In This Topic

    PCCViewer. SearchRequest

    (protected) new SearchRequest()

    The SearchRequest object is created when searching a document. It triggers events to indicate search progress and it has properties to get the search results and status.

    This constructor should not be used directly. Instead, a search request is created by PCCViewer.ViewerControl#search, and it is also made available through the PCCViewer.EventType.SearchPerformed event.

    Example

    // A SearchRequest object is created by and returned from the call to the search method
    var searchRequest = viewerControl.search("FooBar");
    
    

    Members

    (readonly) errorCode :number

    Gets the error code if there was an error. If there was no error, null will be returned.

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Type:

    • number
    See:

    (readonly) errorMessage :string

    Returns a plain text, human-readable, fixed-local message that explains the error condition. If there was no error, null will be returned.

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Type:

    • string
    See:

    (readonly) isComplete :boolean

    Gets a value (true or false) indicating if the search request is complete.

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Type:

    • boolean
    See:

    (readonly) results :Array.<PCCViewer.SearchResult>

    Gets an array of all search results produced by this SearchRequest up until this point.

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Type:

    See:

    (readonly) searchQuery :string

    Gets the search query passed to PCCViewer.ViewerControl#search.

    If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching.

    If an incomplete PCCViewer.ViewerControl~SearchQuery object was passed to search, then the object will be augmented with all options used for searching.

    An ECMA 5 accessor property that is defined only in browsers supporting ECMA 5. This property is not available in the older browsers like IE8.

    Type:

    • string
    See:

    Methods

    cancel()

    Cancels the current search execution and triggers SearchCancelled event.

    Example

    searchRequest.cancel();
    
    

    getErrorCode() → {number}

    Returns the error code if there was an error. If there was no error, null will be returned.

    Example

    var errorCode = searchRequest.getErrorCode();
    
    

    Returns:

    An error code indicating the type of error, or null.

    The possible error codes are:

    • 1010 - An unexpected exception occurred.
    • 1011 - There was a failure retrieving data from the server.
    • ServerSearchUnavailable - Server-side search is not available.
    Type
    number

    getErrorMessage() → {string}

    Returns a plain text, human-readable, fixed-local message that explains the error condition. If there was no error, null will be returned.

    Example

    var errorMessage = searchRequest.getErrorMessage();
    
    

    Returns:

    A plain text error message that explains the error condition, or null.

    Type
    string

    getIsComplete() → {boolean}

    Returns a value (true or false) indicating if the search request is complete.

    Example

    var status = searchRequest.getIsComplete();  // true if search is complete
    
    

    Returns:

    A value indicating if search is complete.

    Type
    boolean

    getPagesWithoutText() → {Array.<number>}

    Returns an array of page numbers that could not be searched because searchable text was not available for the page.

    The set of pages without searchable text may still contain text embedded in a rasterized image, but the viewer is unable to detect or search this text. Therefore it is useful to notify the end user when some pages could not be searched.

    Example

    // Use pagesWithoutText to alert the end user that some pages could not be search.
    var pagesWithoutText = searchRequest.getPagesWithoutText();
    
    

    Returns:

    Returns an array of page numbers, or an empty array if all pages had searchable text.

    Type
    Array.<number>

    getResults() → {Array.<PCCViewer.SearchResult>}

    Returns an array of all search results produced by this SearchRequest up until this point.

    Example

    var searchResults = searchRequest.getResults();
    
    

    Returns:

    An array of SearchResult objects. If no results are found, this will be an empty array.

    Type
    Array.<PCCViewer.SearchResult>

    getSearchQuery() → {PCCViewer.ViewerControl~SearchQuery}

    Returns the search query passed to PCCViewer.ViewerControl#search.

    If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching.

    If an incomplete PCCViewer.ViewerControl~SearchQuery object was passed to search, then the object will be augmented with all options used for searching.

    Example

    var searchQuery = searchRequest.getSearchQuery();
    
    

    Returns:

    The search query for this search request.

    Type
    PCCViewer.ViewerControl~SearchQuery

    off(eventType, handler) → {PCCViewer.SearchRequest}

    Unsubscribe a handler from an event of the SearchRequest.

    Typically, event is unsubscribed when you no longer want further notification of the event.

    Example

    // subscribe
    searchRequest.on(PCCViewer.EventType.SearchCompleted, onSearchCompleted);
    
    // unsubscribe
    searchRequest.off(PCCViewer.EventType.SearchCompleted, onSearchCompleted);
    
    // handler declaration
    function onSearchCompleted(ev) {
        alert("Search completed! Number of hits :" + searchRequest.getResults().length);
    }
    
    

    Parameters:

    Name Type Description
    eventType string

    A string specifying the event type. See PCCViewer.SearchRequest#on for possible values.

    handler function

    The function that was previously subscribed to the event type.

    Returns:

    The SearchRequest object on which this method was called.

    Type
    PCCViewer.SearchRequest

    on(eventType, handler) → {PCCViewer.SearchRequest}

    Subscribe a handler to an event of the SearchRequest.

    Example

    // subscribe
    searchRequest.on(PCCViewer.EventType.SearchCompleted, onSearchCompleted);
    
    // handler declaration
    function onSearchCompleted(ev) {
        alert("Search completed! Number of hits :" + searchRequest.getResults().length);
    }
    
    

    Parameters:

    Name Type Description
    eventType string

    A string that specifies the event type.

    handler function

    The function that will be called whenever the event is triggered.

    Returns:

    The SearchRequest object on which this method was called.

    Type
    PCCViewer.SearchRequest

    Documentation generated by JSDoc 3.6.10 on Thu Oct 31 2024 15:02:24 GMT+0000 (Coordinated Universal Time)