SearchOptions class

SearchOptions class

Provides the options which are used for text search.

An instance of SearchOptions class is used as a parameter in Parser.search method. See the usage examples there.

The SearchOptions type exposes the following members:

Constructors

Constructor Description
init Initializes a new instance of the SearchOptions class.
init Initializes a new instance of the SearchOptions class with the page limit.
init Initializes a new instance of the SearchOptions class which is used to search with the highlight options for the left and the right highlight extraction.
init Initializes a new instance of the SearchOptions class which is used to search with the same highlight options for the left and the right highlight extraction.
init Initializes a new SearchOptions instance used to search without highlight extraction.
init Initializes a new SearchOptions instance used to search by pages without highlight extraction.
init Initializes a new instance of the SearchOptions class with default values.

Properties

Property Description
left_highlight_options The options for the left highlight.
match_case The value indicates whether text case is considered (i.e., not ignored) during a search.
match_whole_word The value indicates whether text search is limited by a whole word.
max_page_index The max page index to search; -1 indicates not set.
right_highlight_options The options for the right highlight.
search_by_pages The value indicating whether the search is performed by pages.
use_regular_expression The value indicating whether a regular expression is used.

Example

from groupdocs.parser import Parser
from groupdocs.parser.options import SearchOptions

with Parser("sample.pdf") as parser:
    # match_case, match_whole_word, use_regular_expression, search_by_pages
    options = SearchOptions(False, False, False, True)
    results = parser.search("lorem", options)
    if results is None:
        print("Search isn't supported for this format.")
    else:
        for result in results:
            print(f"Found on page {result.page_index + 1}: {result.text}")

See Also