Foxit PDF SDK
 All Classes Namespaces Functions Enumerations Enumerator Properties Pages
foxit.pdf.TextSearch Class Reference
Inheritance diagram for foxit.pdf.TextSearch:
foxit.common.Base

Public Types

enum  SearchFlags { SearchFlags.e_SearchNormal = 0x00, SearchFlags.e_SearchMatchCase = 0x01, SearchFlags.e_SearchMatchWholeWord = 0x02, SearchFlags.e_SearchConsecutive = 0x04 }
 Enumeration for searching flags. More...
 

Public Member Functions

 TextSearch (foxit.pdf.PDFDoc document, SearchCancelCallback cancel, int flags)
 Constructor, for a PDF document. More...
 
 TextSearch (foxit.addon.xfa.XFADoc xfa_document, SearchCancelCallback cancel)
 Constructor, for a specified XFA document. More...
 
 TextSearch (TextPage text_page)
 Constructor, for a specified text page. More...
 
 TextSearch (Annot annot)
 Constructor, for a specified PDF annotation. More...
 
 TextSearch (TextSearch other)
 Constructor, with another text search object. More...
 
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...
 
RectFArray GetMatchRects ()
 Get the rectangles of current match pattern. More...
 
string GetMatchSentence ()
 Get the sentence that contains current match pattern. More...
 
int GetMatchSentenceEndIndex ()
 Get the index of the last character of current matched pattern, based on the matched sentence. More...
 
int GetMatchSentenceStartIndex ()
 Get the index of the first character of current matched pattern, based on the matched sentence. More...
 
int GetMatchStartCharIndex ()
 Get the index of the first character of current match pattern, based on current match page. More...
 
bool IsEmpty ()
 Check whether current object is empty or not. More...
 
bool SetEndPage (int page_index)
 Set ending page index. More...
 
bool SetPattern (string key_words)
 Set keywords to search. More...
 
bool SetSearchFlags (int search_flags)
 Set search flags. More...
 
bool SetStartCharacter (int char_index)
 Set starting character index, from where the search process is to be started. More...
 
bool SetStartPage (int page_index)
 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:

Member Enumeration Documentation

Enumeration for searching flags.

Values of this enumeration can be used alone or in combination.

Enumerator
e_SearchNormal 

No special searching options.

e_SearchMatchCase 

If set, match the case of keyword when searching.

e_SearchMatchWholeWord 

If set, match the whole word of keyword when searching.

e_SearchConsecutive 

If set, match the key word consecutively when searching. For example, "CC" will be matched twice in "CCC".

Constructor & Destructor Documentation

foxit.pdf.TextSearch.TextSearch ( foxit.pdf.PDFDoc  document,
SearchCancelCallback  cancel,
int  flags 
)
inline

Constructor, for a PDF document.

User can set a valid SearchCancelCallback 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 SearchCancelCallback object which decides if the searching process needs to be canceled when the callback function is triggered. This can be null which means not to cancel the searching process. If this is not null, it should be a valid SearchCancelCallback object implemented by user.
[in]flagsParsing flags used for parsing text during searching. Please refer to values starting from foxit.pdf.TextPage.TextParseFlags.e_ParseTextNormal and this can be one or combination of these values.
foxit.pdf.TextSearch.TextSearch ( foxit.addon.xfa.XFADoc  xfa_document,
SearchCancelCallback  cancel 
)
inline

Constructor, for a specified XFA document.

Parameters
[in]xfa_documentA valid XFA document object. It should have been loaded by function addon.xfa.XFADoc.StartLoad .
[in]cancelA SearchCancelCallback object which decides if the searching process needs to be canceled when the callback function is triggered. This can be null which means not to cancel the searching process. If this is not null, it should be a valid SearchCancelCallback object implemented by user.
foxit.pdf.TextSearch.TextSearch ( TextPage  text_page)
inline

Constructor, for a specified text page.

Parameters
[in]text_pageA text page object.
foxit.pdf.TextSearch.TextSearch ( Annot  annot)
inline

Constructor, for a specified PDF annotation.

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

Parameters
[in]annotA valid annotation object.
foxit.pdf.TextSearch.TextSearch ( TextSearch  other)
inline

Constructor, with another text search object.

Parameters
[in]otherAnother text search object.

Member Function Documentation

bool foxit.pdf.TextSearch.FindNext ( )
inline

Search for next matched pattern.

Returns
true means the next match is found, while false means no next match can be found or any other error.
bool foxit.pdf.TextSearch.FindPrev ( )
inline

Search for previous matched pattern.

Returns
true means the previous match is found, while false means no previous match can be found or any other error.
int foxit.pdf.TextSearch.GetMatchEndCharIndex ( )
inline

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.
int foxit.pdf.TextSearch.GetMatchPageIndex ( )
inline

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.
RectFArray foxit.pdf.TextSearch.GetMatchRects ( )
inline

Get the rectangles of current match pattern.

Returns
An array of rectangles.
string foxit.pdf.TextSearch.GetMatchSentence ( )
inline

Get the sentence that contains current match pattern.

Returns
The sentence content, which contains current match.
int foxit.pdf.TextSearch.GetMatchSentenceEndIndex ( )
inline

Get the index of the last character of current matched pattern, based on the matched sentence.

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

Returns
The index of the last character of current matched pattern, based on the match sentence, starting from 0. -1 means no matched sentence is found.
int foxit.pdf.TextSearch.GetMatchSentenceStartIndex ( )
inline

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

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

Returns
The index of the first character of current matched pattern, based on the matched sentence, starting from 0. -1 means no matched sentence is found.
int foxit.pdf.TextSearch.GetMatchStartCharIndex ( )
inline

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.
bool foxit.pdf.TextSearch.IsEmpty ( )
inline

Check whether current object is empty or not.

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

Returns
true means current object is empty, while false means not.
bool foxit.pdf.TextSearch.SetEndPage ( int  page_index)
inline

Set ending page index.

This function can only be used for a text search object which is constructed with PDFDoc object or foxit.addon.xfa.XFADoc object. For other case, this function will throw exception foxit.common.ErrorCode.e_ErrUnsupported .
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 PDFDoc.GetPageCount for PDF document or by function addon.xfa.XFADoc.GetPageCount for XFA document.
Returns
true means success, while false means failure.
bool foxit.pdf.TextSearch.SetPattern ( string  key_words)
inline

Set keywords to search.

Parameters
[in]key_wordsThe text content to be searched. It should not be an empty string.
Returns
true means success, while false means failure.
bool foxit.pdf.TextSearch.SetSearchFlags ( int  search_flags)
inline

Set search flags.

If this function is not called, default value foxit.pdf.TextSearch.SearchFlags.e_SearchNormal will be used.

Parameters
[in]search_flagsSearch flags. Please refer to values starting from foxit.pdf.TextSearch.SearchFlags.e_SearchNormal and this can be one or combination of these values.
Returns
true means success, while false means failure.
bool foxit.pdf.TextSearch.SetStartCharacter ( int  char_index)
inline

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 TextPage object or PDFDoc object. For other case, this function will throw exception foxit.common.ErrorCode.e_ErrUnsupported .
If this function is not called for a newly constructed text serach object, default value will be used as the starting character index:

  • 0 will be used as the starting character index for first search started by functionTextSearch.FindNext .
  • (count-1) will be used as the starting character index for first search by function TextSearch.FindPrev .
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
true means success, while false means failure.
bool foxit.pdf.TextSearch.SetStartPage ( int  page_index)
inline

Set starting page index.

This function can only be used for a text search object which is constructed with PDFDoc object or foxit.addon.xfa.XFADoc object. For other case, this function will throw exception foxit.common.ErrorCode.e_ErrUnsupported .
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 PDFDoc.GetPageCount for PDF document or by function addon.xfa.XFADoc.GetPageCount for XFA document.
Returns
true means success, while false means failure.