此类可以在PDF文档/XFA文档/文本页面或PDF注释的外观中构造文本搜索。 它提供进行文本搜索和获取搜索结果的函数:
◆ SearchFlags
搜索标志的枚举。
此枚举的值可以单独使用或组合使用。
| 枚举值 |
|---|
| e_SearchNormal | 无特殊搜索选项。
|
| e_SearchMatchCase | 如果设置,搜索时匹配关键字的大小写。
|
| e_SearchMatchWholeWord | 如果设置,搜索时匹配关键字的完整单词。
|
| e_SearchConsecutive | 如果设置,搜索时连续匹配关键字。例如,"CC"在"CCC"中将被匹配两次。
|
| e_SearchNotMatchFullWidth | 如果设置,在搜索期间忽略全角字符并将所有字符视为标准ASCII或标准宽度字符。
|
◆ TextSearch() [1/5]
◆ TextSearch() [2/5]
◆ TextSearch() [3/5]
◆ TextSearch() [4/5]
对于指定PDF注释的构造函数。
目前,仅支持在以下注释类型的外观中搜索: 自由文本注释、印章注释、小部件注释和线条注释。
- 参数
-
◆ TextSearch() [5/5]
| foxit::pdf::TextSearch::TextSearch |
( |
const TextSearch & |
other | ) |
|
◆ FindNext()
| bool foxit::pdf::TextSearch::FindNext |
( |
| ) |
|
搜索下一个匹配的模式。
- 返回
- true 表示找到下一个匹配,false 表示找不到下一个匹配或 发生其他错误。
◆ FindPrev()
| bool foxit::pdf::TextSearch::FindPrev |
( |
| ) |
|
搜索上一个匹配的模式。
- 返回
- true 表示找到上一个匹配,false 表示找不到上一个匹配或 发生其他错误。
◆ GetMatchEndCharIndex()
| int foxit::pdf::TextSearch::GetMatchEndCharIndex |
( |
| ) |
const |
基于当前匹配页面,获取当前匹配模式最后一个字符的索引。
- 返回
- 当前匹配页面中最后一个字符的索引,从0开始。 -1表示未找到匹配的句子。
◆ GetMatchPageIndex()
| int foxit::pdf::TextSearch::GetMatchPageIndex |
( |
| ) |
const |
获取当前匹配所属的页面索引。
此函数只能用于PDF文档或XFA文档中的文本搜索。
- 返回
- 包含当前匹配的页面索引,从0开始。 -1表示未找到匹配的模式。
◆ GetMatchRects()
| RectFArray foxit::pdf::TextSearch::GetMatchRects |
( |
| ) |
const |
◆ GetMatchSentence()
| WString foxit::pdf::TextSearch::GetMatchSentence |
( |
| ) |
|
获取包含当前匹配模式的句子。
- 返回
- 包含当前匹配的句子内容。
◆ GetMatchSentenceEndIndex()
| int foxit::pdf::TextSearch::GetMatchSentenceEndIndex |
( |
| ) |
|
基于匹配句子,获取当前匹配模式最后一个字符的索引。
在一个句子中,可能有超过2个匹配模式。此函数与函数 GetMatchSentenceStartIndex 一起, 可以帮助确认句子中的哪个模式就是当前匹配的模式。
- 返回
- 基于匹配句子的当前匹配模式最后一个字符的索引,从0开始。 -1表示未找到匹配的句子。
◆ GetMatchSentenceStartIndex()
| int foxit::pdf::TextSearch::GetMatchSentenceStartIndex |
( |
| ) |
|
基于匹配句子,获取当前匹配模式第一个字符的索引。
在一个句子中,可能有超过2个匹配模式。此函数与函数 GetMatchSentenceEndIndex 一起, 可以帮助确认句子中的哪个模式就是当前匹配的模式。
- 返回
- 基于匹配句子的当前匹配模式第一个字符的索引,从0开始。 -1表示未找到匹配的句子。
◆ GetMatchStartCharIndex()
| int foxit::pdf::TextSearch::GetMatchStartCharIndex |
( |
| ) |
const |
基于当前匹配页面,获取当前匹配模式第一个字符的索引。
- 返回
- 当前匹配页面中第一个字符的索引,从0开始。 -1表示未找到匹配的句子。
◆ IsEmpty()
| bool foxit::pdf::TextSearch::IsEmpty |
( |
| ) |
const |
检查当前对象是否为空。
当前对象为空时,意味着当前对象无用。
- 返回
- true 表示当前对象为空,false 表示不为空。
◆ operator !=()
| bool foxit::pdf::TextSearch::operator != |
( |
const TextSearch & |
other | ) |
const |
不等于操作符。
- 参数
-
| [in] | other | 另一个文本搜索对象。此函数将检查当前对象是否不等于这个对象。 |
- 返回
- true 表示不相等,false 表示相等。
◆ operator=()
赋值操作符。
- 参数
-
| [in] | other | 另一个文本搜索对象,其值将被赋给当前对象。 |
- 返回
- 对当前对象自身的引用。
◆ operator==()
| bool foxit::pdf::TextSearch::operator== |
( |
const TextSearch & |
other | ) |
const |
等于操作符。
- 参数
-
| [in] | other | 另一个文本搜索对象。此函数将检查当前对象是否等于这个对象。 |
- 返回
- true 表示相等,false 表示不相等。
◆ SetEndPage()
| bool foxit::pdf::TextSearch::SetEndPage |
( |
int |
page_index | ) |
|
◆ SetPattern()
| bool foxit::pdf::TextSearch::SetPattern |
( |
const wchar_t * |
key_words, |
|
|
bool |
is_regex_search = false |
|
) |
| |
设置要搜索的关键词。
- 参数
-
| [in] | key_words | 要搜索的文本内容。它不应是空字符串。 |
| [in] | is_regex_search | true 表示启用正则表达式搜索,false 表示不启用。 如果启用正则表达式搜索,函数 TextSearch::SetSearchFlags 设置的搜索标志将被忽略。默认值:false。 |
- 返回
- true 表示成功,false 表示失败。
◆ SetSearchFlags()
| bool foxit::pdf::TextSearch::SetSearchFlags |
( |
uint32 |
search_flags | ) |
|
◆ SetStartCharacter()
| bool foxit::pdf::TextSearch::SetStartCharacter |
( |
int |
char_index | ) |
|
设置起始字符索引,搜索过程从该位置开始。
此函数只能用于使用 TextPage 对象或 PDFDoc 对象 构造的文本搜索对象。对于其他情况,此函数将抛出异常 foxit::e_ErrUnsupported。
如果不为新构造的文本搜索对象调用此函数, 将使用默认值作为起始字符索引:
- 参数
-
| [in] | char_index | 搜索过程开始的起始字符索引。 有效范围:从0到(count-1)。count 表示搜索过程起始页面中的字符数量。 |
- 返回
- true 表示成功,false 表示失败。
◆ SetStartPage()
| bool foxit::pdf::TextSearch::SetStartPage |
( |
int |
page_index | ) |
|