TextFragmentAbsorber

TextFragmentAbsorber

Overview

TextFragmentAbsorber is a class in Aspose.PDF FOSS for Python.

Absorbs text fragments from a PDF page or document.

This class provides 5 methods for working with TextFragmentAbsorber objects in Python programs. Available methods include: __init__, apply_for_all_fragments, remove_all_text, reset, visit. All public members are accessible to any Python application after installing the Aspose.PDF FOSS for Python package. Properties: errors, has_errors, phrase, regex_results, text_fragments, text_replace_options, and 1 more.

Properties

NameTypeAccessDescription
text_fragmentslist[TextFragment]ReadList of :class:TextFragment objects found by the last visit.
regex_resultslist[RegexResult]ReadList of :class:RegexResult objects (populated on regex search).
errorslist[Any]ReadErrors collected during the last visit, if any.
phrasestr | NoneReadGets the phrase.
text_search_optionsTextSearchOptionsReadGets the text search options.
text_replace_optionsAny | NoneReadGets the text replace options.
has_errorsboolReadGets the has errors.

Methods

SignatureDescription
__init__(phrase: str | None, text_search_options: TextSearchOptions | None, text_replace_options: Any | None)Calls init(phrase, text_search_options, text_replace_options) on this TextFragmentAbsorber instance.
visit(page_or_doc: Any)Process page_or_doc and collect matching text fragments.
reset()Clear all collected fragments, regex results and errors.
remove_all_text()Remove all collected text fragments (alias for reset without clearing errors).
apply_for_all_fragments(action: Callable[[TextFragment], Any])list[Any]Apply action to every collected fragment and return the results.

See Also