Foxit PDF SDK
fsdk.TextSearch Class Reference

Public Member Functions

def FindNext ()
 Search for next matched pattern.
More...
 
def FindPrev ()
 Search for previous matched pattern.
More...
 
def GetMatchEndCharIndex ()
 Get the index of the last character of current match pattern, based on current match page.
More...
 
def GetMatchPageIndex ()
 Get the page index, to which current match belongs.
More...
 
def GetMatchRects ()
 Get the rectangles of current match pattern.
More...
 
def GetMatchSentence ()
 Get the sentence that contains current match pattern.
More...
 
def GetMatchSentenceEndIndex ()
 Get the index of the last character of current matched pattern, based on the matched sentence.
More...
 
def GetMatchSentenceStartIndex ()
 Get the index of the first character of current matched pattern, based on the matched sentence.
More...
 
def GetMatchStartCharIndex ()
 Get the index of the first character of current match pattern, based on current match page.
More...
 
def IsEmpty ()
 Check whether current object is empty or not.
More...
 
def SetEndPage (page_index)
 Set ending page index.
More...
 
def SetPattern (key_words, is_regex_search)
 Set keywords to search.
More...
 
def SetSearchFlags (search_flags)
 Set search flags.
More...
 
def SetStartCharacter (char_index)
 Set starting character index, from where the search process is to be started.
More...
 
def SetStartPage (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 Function Documentation

◆ FindNext()

def fsdk.TextSearch.FindNext ( )

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.

◆ FindPrev()

def fsdk.TextSearch.FindPrev ( )

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.

◆ GetMatchEndCharIndex()

def fsdk.TextSearch.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()

def fsdk.TextSearch.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()

def fsdk.TextSearch.GetMatchRects ( )

Get the rectangles of current match pattern.

Returns
An array of rectangles.

◆ GetMatchSentence()

def fsdk.TextSearch.GetMatchSentence ( )

Get the sentence that contains current match pattern.

Returns
The sentence content, which contains current match.

◆ GetMatchSentenceEndIndex()

def fsdk.TextSearch.GetMatchSentenceEndIndex ( )

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.

◆ GetMatchSentenceStartIndex()

def fsdk.TextSearch.GetMatchSentenceStartIndex ( )

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.

◆ GetMatchStartCharIndex()

def fsdk.TextSearch.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.

◆ IsEmpty()

def fsdk.TextSearch.IsEmpty ( )

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.

◆ SetEndPage()

def fsdk.TextSearch.SetEndPage (   page_index)

Set ending page index.

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

◆ SetPattern()

def fsdk.TextSearch.SetPattern (   key_words,
  is_regex_search 
)

Set keywords to search.

Parameters
[in]key_wordsThe text content to be searched. It should not be an empty string.
[in]is_regex_searchtrue means to enable regular expression search, while false means not. If regular expression search is enabled, the search flag set by function fsdk.TextSearch.SetSearchFlags will be ignored. Default value: false.
Returns
true means success, while false means failure.

◆ SetSearchFlags()

def fsdk.TextSearch.SetSearchFlags (   search_flags)

Set search flags.

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

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

◆ SetStartCharacter()

def fsdk.TextSearch.SetStartCharacter (   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 TextPage object or PDFDoc object. For other case, this function will throw exception fsdk.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:


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.

◆ SetStartPage()

def fsdk.TextSearch.SetStartPage (   page_index)

Set starting page index.

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