extract_text method

On this page

extract_text

Extracts a text from the document to which TocItem object refers.

def extract_text(self):
    ...

Returns: io.TextIOBase: An instance with the extracted text.

Example

    from groupdocs.parser import Parser

    with Parser("./sample.docx") as parser:
        toc_items = parser.get_toc()
        if toc_items is None:
            print("Table of contents extraction isn't supported")
        else:
            for toc_item in toc_items:
                with toc_item.extract_text() as reader:
                    print("----")
                    print(reader.read())
    ```

### See Also
* class [`TocItem`](/parser/python-net/groupdocs.parser.data/tocitem/)

On this page