Foxit PDF SDK
|
Public Types | |
enum | SearchFlags { e_SearchNormal = 0x00, e_SearchMatchCase = 0x01, e_SearchMatchWholeWord = 0x02, e_SearchConsecutive = 0x04 } |
Enumeration for searching flags. More... | |
Public Member Functions | |
TextSearch (const PDFDoc &document, SearchCancelCallback *cancel=0, int flags=foxit::pdf::TextPage::e_ParseTextNormal) | |
Constructor, for a PDF document. More... | |
TextSearch (const foxit::addon::xfa::XFADoc &xfa_document, foxit::pdf::SearchCancelCallback *cancel=0) | |
Constructor, for a specified XFA document. More... | |
TextSearch (const foxit::pdf::TextPage &text_page) | |
Constructor, for a specified text page. More... | |
TextSearch (const foxit::pdf::annots::Annot &annot) | |
Constructor, for a specified PDF annotation. More... | |
TextSearch (const TextSearch &other) | |
Constructor, with another text search object. More... | |
~TextSearch () | |
Destructor. | |
bool | FindNext () |
Search for next matched pattern. More... | |
bool | FindPrev () |
Search for previous matched pattern. More... | |
int | GetMatchEndCharIndex () const |
Get the index of the last character of current match pattern, based on current match page. More... | |
int | GetMatchPageIndex () const |
Get the page index, to which current match belongs. More... | |
RectFArray | GetMatchRects () const |
Get the rectangles of current match pattern. More... | |
WString | 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 () const |
Get the index of the first character of current match pattern, based on current match page. More... | |
bool | IsEmpty () const |
Check whether current object is empty or not. More... | |
bool | operator != (const TextSearch &other) const |
Not equal operator. More... | |
TextSearch & | operator= (const TextSearch &other) |
Assign operator. More... | |
bool | operator== (const TextSearch &other) const |
Equal operator. More... | |
bool | SetEndPage (int page_index) |
Set ending page index. More... | |
bool | SetPattern (const wchar_t *key_words) |
Set keywords to search. More... | |
bool | SetSearchFlags (uint32 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... | |
![]() | |
FS_HANDLE | Handle () const |
Get the handle of current object. More... | |
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:
Enumeration for searching flags.
Values of this enumeration can be used alone or in combination.
|
explicit |
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.
[in] | document | A valid PDF document object. |
[in] | cancel | A 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. Default value: NULL. |
[in] | flags | Parsing flags used for parsing text during searching. Please refer to values starting from TextPage::e_ParseTextNormal and this can be one or combination of these values. Default value: TextPage::e_ParseTextNormal. |
|
explicit |
Constructor, for a specified XFA document.
[in] | xfa_document | A valid XFA document object. It should have been loaded by function addon::xfa::XFADoc::StartLoad. |
[in] | cancel | A 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. Default value: NULL. |
|
explicit |
Constructor, for a specified text page.
[in] | text_page | A text page object. |
|
explicit |
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.
[in] | annot | A valid annotation object. |
foxit::pdf::TextSearch::TextSearch | ( | const TextSearch & | other | ) |
Constructor, with another text search object.
[in] | other | Another text search object. |
bool foxit::pdf::TextSearch::FindNext | ( | ) |
Search for next matched pattern.
bool foxit::pdf::TextSearch::FindPrev | ( | ) |
Search for previous matched pattern.
int foxit::pdf::TextSearch::GetMatchEndCharIndex | ( | ) | const |
Get the index of the last character of current match pattern, based on current match page.
int foxit::pdf::TextSearch::GetMatchPageIndex | ( | ) | const |
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.
RectFArray foxit::pdf::TextSearch::GetMatchRects | ( | ) | const |
Get the rectangles of current match pattern.
WString foxit::pdf::TextSearch::GetMatchSentence | ( | ) |
Get the sentence that contains current match pattern.
int foxit::pdf::TextSearch::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.
int foxit::pdf::TextSearch::GetMatchStartCharIndex | ( | ) | const |
Get the index of the first character of current match pattern, based on current match page.
bool foxit::pdf::TextSearch::IsEmpty | ( | ) | const |
Check whether current object is empty or not.
When the current object is empty, that means current object is useless.
bool foxit::pdf::TextSearch::operator != | ( | const TextSearch & | other | ) | const |
Not equal operator.
[in] | other | Another text search object. This function will check if current object is not equal to this one. |
TextSearch& foxit::pdf::TextSearch::operator= | ( | const TextSearch & | other | ) |
Assign operator.
[in] | other | Another text search object, whose value would be assigned to current object. |
bool foxit::pdf::TextSearch::operator== | ( | const TextSearch & | other | ) | const |
Equal operator.
[in] | other | Another text search object. This function will check if current object is equal to this one. |
bool foxit::pdf::TextSearch::SetEndPage | ( | int | page_index | ) |
Set ending page index.
This function can only be used for a text search object which is constructed with PDFDoc object or addon::xfa::XFADoc object. For other case, this function will throw exception foxit::e_ErrUnsupported.
If this function is not called, default value count-1 will be used as the ending page index.
[in] | page_index | Index 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. |
bool foxit::pdf::TextSearch::SetPattern | ( | const wchar_t * | key_words | ) |
Set keywords to search.
[in] | key_words | The text content to be searched. It should not be an empty string. |
bool foxit::pdf::TextSearch::SetSearchFlags | ( | uint32 | search_flags | ) |
Set search flags.
If this function is not called, default value TextSearch::e_SearchNormal will be used.
[in] | search_flags | Search flags. Please refer to values starting from TextSearch::e_SearchNormal and this can be one or combination of these values. |
bool foxit::pdf::TextSearch::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 TextPage object or PDFDoc object. For other case, this function will throw exception foxit::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:
[in] | char_index | Starting 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. |
bool foxit::pdf::TextSearch::SetStartPage | ( | int | page_index | ) |
Set starting page index.
This function can only be used for a text search object which is constructed with PDFDoc object or addon::xfa::XFADoc object. For other case, this function will throw exception foxit::e_ErrUnsupported.
If this function is not called, default value 0 will be used as the starting page index.
[in] | page_index | Index 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. |