PrizmDoc Viewer v13.25 Release - Updated
PrizmDoc Viewer / API Reference / Viewer Control / Namespace: PCCViewer / Class: SearchResult
In This Topic
    Class: SearchResult
    In This Topic

    PCCViewer. SearchResult

    new SearchResult()

    The SearchResult object is created when searching a document. It represents a "search hit", the text in the document that matched a search term in the searchQuery, which was passed to PCCViewer.ViewerControl#search.

    This constructor should not be used directly. Instead, only access search results created by PCCViewer.ViewerControl#search, through the PCCViewer.SearchRequest object.

    See:

    Members

    (readonly) boundingRectangle :Object

    Gets the bounding rectangle of the search result.

    This is 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:

    • Object
    See:

    (readonly) context :string

    Gets the search result text and some surrounding text.

    The number of character in the context before and after the search result text can be configured using the PCCViewer.ViewerControl~SearchQuery passed to the PCCViewer.ViewerControl#search method.

    This is 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) highlightColor :string

    Gets the highlight color of the search result, in hex notation (e.g. "#F1F1F1").

    The highlight color can be specified in the PCCViewer.ViewerControl~SearchQuery passed to the PCCViewer.ViewerControl#search method. If a highlight color is not specified on the searchQuery, then a pseudo-random color is chosen.

    This is 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) id :number

    Gets the ID of the search result.

    The ID is unique only to results in the current search request, and it may be repeated in later search requests.

    This is 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) pageNumber :number

    Gets the page number of the document, on which the search result starts.

    If the search result text is contained on a single page, this returns the page number of that page. If the search result text spans multiple pages, this returns the page number of the first page.

    This is 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) searchTerm :PCCViewer.ViewerControl~SearchTerm|PCCViewer.ViewerControl~ProximitySearchTerm

    Gets the search term object from the searchQuery object that was passed to the PCCViewer.ViewerControl#search method.

    If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchTerm object generated from the string.

    The returned object will be augmented with all options used for searching.

    This is 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) startIndexInContext :number

    Gets the start index of the search result text within the context text returned by PCCViewer.SearchResult#getContext.

    This is 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) text :string

    Gets the search result text. This is the text that matched the search query/term.

    This is 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

    getBoundingRectangle() → {Object}

    Gets the bounding rectangle for the search result.

    Example

    if (searchResult.getBoundingRectangle) {
        var boundingRectangle = searchResult.getBoundingRectangle();
    }
    
    
    See:

    Returns:

    A rectangle object of the type {x: xValue, y: yValue, width: widthValue, height: heightValue}.

    Type
    Object

    getContext() → {string}

    Gets the search result text and some surrounding text.

    The number of character in the context before and after the search result text can be configured using the PCCViewer.ViewerControl~SearchQuery passed to the PCCViewer.ViewerControl#search method.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    
    result.getText();                 // e.g. "document"
    result.getContext();              // e.g. "... the full spectrum of document, content, & imaging s..."
    result.getStartIndexInContext();  // e.g. 25
    
    
    See:

    Returns:

    The context of the search result.

    Type
    string

    getHighlightColor() → {string}

    Gets the highlight color of the search result, in hex notation (e.g. "#F1F1F1").

    The highlight color can be specified in the PCCViewer.ViewerControl~SearchQuery passed to the PCCViewer.ViewerControl#search method. If a highlight color is not specified on the searchQuery, then a pseudo-random color is chosen.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    var highlightColor = result.getHighlightColor();
    
    

    Returns:

    The color of the search result highlight, in hexadecimal notation.

    Type
    string

    getId() → {number}

    Gets the ID of the search result.

    The ID is unique only to results in the current search request, and it may be repeated in later search requests.

    Example

    var results = searchRequest.getResults();
    var result = results[0];
    var id = result.getId();
    
    
    See:

    Returns:

    The ID of the search result.

    Type
    number

    getPageNumber() → {number}

    Gets the page number of the document, on which the search result starts.

    If the search result text is contained on a single page, this returns the page number of that page. If the search result text spans multiple pages, this returns the page number of the first page.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    var pageNumber = result.getPageNumber();
    alert("Search result found on page: " + pageNumber);
    
    

    Returns:

    The page number on which the search result starts.

    Type
    number

    getSearchTerm() → {PCCViewer.ViewerControl~SearchTerm|PCCViewer.ViewerControl~ProximitySearchTerm}

    Gets the search term object from the searchQuery object that was passed to the PCCViewer.ViewerControl#search method.

    If a string was passed to the search method, then this will return a PCCViewer.ViewerControl~SearchTerm object generated from the string.

    The returned object will be augmented with all options used for searching.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    var searchTerm = result.getSearchTerm();
    alert("This search result matched the search term: " + searchTerm.searchTerm);
    
    

    Returns:

    The search term of the search result.

    Type
    PCCViewer.ViewerControl~SearchTerm | PCCViewer.ViewerControl~ProximitySearchTerm

    getStartIndexInContext() → {number}

    Gets the start index of the search result text within the context text returned by PCCViewer.SearchResult#getContext.

    Example

    var results = searchRequest.getResults();
    var result = results[0];
    var startIndex = result.getStartIndexInContext();
    
    

    Returns:

    The start index of the search result text within the context text.

    Type
    number

    getStartIndexInPage() → {number}

    Gets the start index of the search result text, within the entire text of the page that the result is on.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    var startIndex = result.getStartIndexInPage();
    alert("The search result starts a character " + startIndex + " on the page.");
    
    
    See:

    Returns:

    The start index of the matched text in the page.

    Type
    number

    getText() → {string}

    Gets the search result text. This is the text that matched the search query/term.

    Example

    var results = searchRequest.getResults()
    var result = results[0];
    var text = result.getText();
    alert("Search matched the text: " + text);
    
    

    Returns:

    The search result text.

    Type
    string

    Documentation generated by JSDoc 3.6.10 on Thu Sep 21 2023 17:47:53 GMT+0000 (Coordinated Universal Time)