Document

Overview

Document is a class in Aspose.Words FOSS for Python. Inherits from: BaseModel.

The Document class represents a Word document and provides the get_text() method to extract the full plain‑text content of the file.

This class provides 5 methods for working with Document objects in Python programs. Available methods include: find_style, get_child_nodes, get_list, headings, resolve_list_level. All public members are accessible to any Python application after installing the Aspose.Words FOSS for Python package. Properties: all_paragraphs, all_tables, default_tab_stop, doc_defaults_font, footer_paragraphs, header_paragraphs, and 8 more.

Properties

NameTypeAccessDescription
header_paragraphslist[Paragraph]ReadFlat list of header paragraphs collected from all sections.
footer_paragraphslist[Paragraph]ReadFlat list of footer paragraphs collected from all sections.
all_paragraphslist[Paragraph]ReadFlat list of direct body paragraphs only (excludes table cells).
tableslist[Table]ReadFlat list of all top-level tables in the body.
all_tableslist[Table]ReadAlias for tables (backwards compatibility).
textstrReadPlain text of the whole document (body paragraphs only).
typestrReadGets the type.
default_tab_stopfloatReadGets the default tab stop.
page_colorstrReadGets the page color.
page_countintReadGets the page count.
doc_defaults_fontOptional[Font]ReadGets the doc defaults font.
styleslist[Style]ReadGets the styles.
listslist[DocList]ReadGets the lists.
sectionslist[Section]ReadGets the sections.

Methods

SignatureDescription
get_child_nodes(node_type: int, deep: bool)listChild nodes, optionally filtered by :class:NodeType.
get_list(list_id: int)DocList | NoneLook up a list definition by ID.
resolve_list_level(list_id: int, level_num: int)ListLevel | NoneResolve the effective ListLevel for a list-id + level pair,
    applying any ``<w:lvlOverride>`` formatting from the concrete

    ``<w:num>`` element. |

| find_style(name: str)Style \| None | Look up a style by its exact name. | | headings(max_level: int)list[Paragraph] | All heading paragraphs up to a given outline level. |

See Also

 English