Foxit PDF SDK
FSTextSearch Class Reference
Inheritance diagram for FSTextSearch:
FSBase

Instance Methods

(BOOL) - findNext
 Search for next matched pattern.
More...
 
(BOOL) - findPrev
 Search for previous matched pattern.
More...
 
(int) - getMatchEndCharIndex
 Get the index of the last character of current match pattern, based on current match page.
More...
 
(int) - getMatchPageIndex
 Get the page index, to which current match belongs.
More...
 
(FSRectFArray *) - getMatchRects
 Get the rectangles of current match pattern.
More...
 
(NSString *) - getMatchSentence
 Get the sentence that contains current match pattern.
More...
 
(int) - getMatchSentenceStartIndex
 Get the index of the first character of current match pattern, based on the match sentence.
More...
 
(int) - getMatchStartCharIndex
 Get the index of the first character of current match pattern, based on current match page.
More...
 
(id) - initWithAnnot:
 Constructor, for a specified PDF annotation.
More...
 
(id) - initWithDocument:cancel:flags:
 Constructor, for a PDF document.
More...
 
(id) - initWithOther:
 Constructor, with another text search object.
More...
 
(id) - initWithText_page:
 Constructor, for a specified text page.
More...
 
(id) - initWithXfa_document:cancel:
 Constructor, for a specified XFA document.
More...
 
(BOOL) - isEmpty
 Check whether current object is empty or not.
More...
 
(BOOL) - setEndPage:
 Set ending page index.
More...
 
(BOOL) - setPattern:
 Set keywords to search.
More...
 
(BOOL) - setSearchFlags:
 Set search flags.
More...
 
(BOOL) - setStartCharacter:
 Set starting character index, from where the search process is to be started.
More...
 
(BOOL) - setStartPage:
 Set starting page index.
More...
 

Detailed Description

This class can construct text search in a PDF document/an XFA document/a text page or in a PDF annotation's appearance. It offers functions to do a text search and get the searching result:


Method Documentation

◆ findNext()

- (BOOL) findNext

Search for next matched pattern.

Returns
YES means the next match is found, while NO means no next match can be found or any other error.

◆ findPrev()

- (BOOL) findPrev

Search for previous matched pattern.

Returns
YES means the previous match is found, while NO means no previous match can be found or any other error.

◆ getMatchEndCharIndex()

- (int) getMatchEndCharIndex

Get the index of the last character of current match pattern, based on current match page.

Returns
The index of the last character, in current match page, starting from 0. -1 means no matched sentence is found.

◆ getMatchPageIndex()

- (int) getMatchPageIndex

Get the page index, to which current match belongs.

This function can only be used for a text search in PDF document or in XFA document.

Returns
The index of the page, which contains the current match, starting from 0. -1 means not matched pattern has been found.

◆ getMatchRects()

- (FSRectFArray *) getMatchRects

Get the rectangles of current match pattern.

Returns
An array of rectangles.

◆ getMatchSentence()

- (NSString *) getMatchSentence

Get the sentence that contains current match pattern.

Returns
The sentence content, which contains current match.

◆ getMatchSentenceStartIndex()

- (int) getMatchSentenceStartIndex

Get the index of the first character of current match pattern, based on the match sentence.

In a sentence, there may be more than 2 match patterns. This function can help to confirm which pattern in the sentence is just current match pattern.

Returns
The index of the first character of current match pattern, based on the match sentence, starting from 0. -1 means no matched sentence is found.

◆ getMatchStartCharIndex()

- (int) getMatchStartCharIndex

Get the index of the first character of current match pattern, based on current match page.

Returns
The index of the first character, in current match page, starting from 0. -1 means no matched sentence is found.

◆ initWithAnnot:()

- (id) initWithAnnot: (FSAnnot*)  annot

Constructor, for a specified PDF annotation.

Currently, only support to search in appearance of following annotation types: free text annotation, stamp annotation, widget annotation, and line annotation.

Parameters
[in]annotA valid annotation object.

◆ initWithDocument:cancel:flags:()

- (id) initWithDocument: (FSPDFDoc*)  document
cancel: (id<FSSearchCancelCallback>)  cancel
flags: (int)  flags 

Constructor, for a PDF document.

User can set a valid object in order to decide whether to cancel the searching process or not when the callback function in SearchCancelCallback is triggered.

Parameters
[in]documentA valid PDF document object.
[in]cancelA object which decides if the searching process needs to be canceled when the callback function is triggered. This can be nil which means not to cancel the searching process. If this is not nil, it should be a valid object implemented by user.
[in]flagsParsing flags used for parsing text during searching. Please refer to values starting from FSTextPageParseTextNormal and this can be one or combination of these values.

◆ initWithOther:()

- (id) initWithOther: (FSTextSearch*)  other

Constructor, with another text search object.

Parameters
[in]otherAnother text search object.

◆ initWithText_page:()

- (id) initWithText_page: (FSTextPage*)  text_page

Constructor, for a specified text page.

Parameters
[in]text_pageA text page object.

◆ initWithXfa_document:cancel:()

- (id) initWithXfa_document: (FSXFADoc*)  xfa_document
cancel: (id<FSSearchCancelCallback>)  cancel 

Constructor, for a specified XFA document.

Parameters
[in]xfa_documentA valid XFA document object. It should have been loaded by function FSXFADoc::startLoad:.
[in]cancelA object which decides if the searching process needs to be canceled when the callback function is triggered. This can be nil which means not to cancel the searching process. If this is not nil, it should be a valid object implemented by user.

◆ isEmpty()

- (BOOL) isEmpty

Check whether current object is empty or not.

When the current object is empty, that means current object is useless.

Returns
YES means current object is empty, while NO means not.

◆ setEndPage:()

- (BOOL) setEndPage: (int)  page_index

Set ending page index.

This function can only be used for a text search object which is constructed with FSPDFDoc object or FSXFADoc object. For other case, this function will throw exception FSErrUnsupported.
If this function is not called, default value count-1 will be used as the ending page index.

Parameters
[in]page_indexIndex of the page, from which the search ended. Valid range: from 0 to (count-1). count is returned by function FSPDFDoc::getPageCount for PDF document or by function FSXFADoc::getPageCount for XFA document.
Returns
YES means success, while NO means failure.

◆ setPattern:()

- (BOOL) setPattern: (NSString *)  key_words

Set keywords to search.

Parameters
[in]key_wordsThe text content to be searched. It should not be an empty string.
Returns
YES means success, while NO means failure.

◆ setSearchFlags:()

- (BOOL) setSearchFlags: (unsigned int)  search_flags

Set search flags.

If this function is not called, default value FSTextSearchSearchNormal will be used.

Parameters
[in]search_flagsSearch flags. Please refer to values starting from FSTextSearchSearchNormal and this can be one or combination of these values.
Returns
YES means success, while NO means failure.

◆ setStartCharacter:()

- (BOOL) setStartCharacter: (int)  char_index

Set starting character index, from where the search process is to be started.

This function can only be used for a text search object which is constructed with FSTextPage object or FSPDFDoc object. For other case, this function will throw exception FSErrUnsupported.
If this function is not called for a newly constructed text serach object, default value will be used as the starting character index:


Parameters
[in]char_indexStarting character index, from where the search process is to be started. Valid range: from 0 to (count-1). count means the count of characters in the starting page for search process.
Returns
YES means success, while NO means failure.

◆ setStartPage:()

- (BOOL) setStartPage: (int)  page_index

Set starting page index.

This function can only be used for a text search object which is constructed with FSPDFDoc object or FSXFADoc object. For other case, this function will throw exception FSErrUnsupported.
If this function is not called, default value 0 will be used as the starting page index.

Parameters
[in]page_indexIndex of the page, from which the search starts. Valid range: from 0 to (count-1). count is returned by function FSPDFDoc::getPageCount for PDF document or by function FSXFADoc::getPageCount for XFA document.
Returns
YES means success, while NO means failure.