ImageGear .NET v25.1 - Updated
IPCC.SearchRequest
API Reference > ViewerControl API > IPCC.SearchRequest

Class: SearchRequest

(protected) IPCC.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 IPCC.ViewerControl#search, and it is also made available through the IPCC.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.<IPCC.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 IPCC.ViewerControl#search. If a string was passed to the `search` method, then this will return a IPCC.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching. If an incomplete IPCC.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.
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
Example
var errorCode = searchRequest.getErrorCode();

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.
Returns:
A plain text error message that explains the error condition, or null.
Type
string
Example
var errorMessage = searchRequest.getErrorMessage();

getIsComplete() → {boolean}

Returns a value (`true` or `false`) indicating if the search request is complete.
Returns:
A value indicating if search is complete.
Type
boolean
Example
var status = searchRequest.getIsComplete();  // true if search is complete

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._
Returns:
Returns an array of page numbers, or an empty array if all pages had searchable text.
Type
Array.<number>
Example
// Use pagesWithoutText to alert the end user that some pages could not be search.
var pagesWithoutText = searchRequest.getPagesWithoutText();

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

Returns an array of all search results produced by this `SearchRequest` up until this point.
Returns:
An array of `SearchResult` objects. If no results are found, this will be an empty array.
Type
Array.<IPCC.SearchResult>
Example
var searchResults = searchRequest.getResults();

getSearchQuery() → {IPCC.ViewerControl~SearchQuery}

Returns the search query passed to IPCC.ViewerControl#search. If a string was passed to the `search` method, then this will return a IPCC.ViewerControl~SearchQuery object. The object will contain one search term (the provided string) and the options used for searching. If an incomplete IPCC.ViewerControl~SearchQuery object was passed to `search`, then the object will be augmented with all options used for searching.
Returns:
The search query for this search request.
Type
IPCC.ViewerControl~SearchQuery
Example
var searchQuery = searchRequest.getSearchQuery();

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

Unsubscribe a handler from an event of the `SearchRequest`. Typically, event is unsubscribed when you no longer want further notification of the event.
Parameters:
Name Type Description
eventType string A string specifying the event type. See IPCC.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
IPCC.SearchRequest
Example
// subscribe
searchRequest.on(IPCC.EventType.SearchCompleted, onSearchCompleted);

// unsubscribe
searchRequest.off(IPCC.EventType.SearchCompleted, onSearchCompleted);

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

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

Subscribe a handler to an event of the `SearchRequest`.
Parameters:
Name Type Description
eventType string A string that specifies the event type. - "SearchCompleted" - IPCC.EventType.SearchCompleted - "SearchFailed" - IPCC.EventType.SearchFailed - "SearchCancelled" - IPCC.EventType.SearchCancelled - "SearchResultsAvailable" - IPCC.EventType.SearchResultsAvailable - "PartialSearchResultsAvailable" - IPCC.EventType.PartialSearchResultsAvailable
handler function The function that will be called whenever the event is triggered.
Returns:
The `SearchRequest` object on which this method was called.
Type
IPCC.SearchRequest
Example
// subscribe
searchRequest.on(IPCC.EventType.SearchCompleted, onSearchCompleted);

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