docx_parser_converter.docx_parsers.models.document_models module

class docx_parser_converter.docx_parsers.models.document_models.DocMargins(*, top_pt: float | None = None, right_pt: float | None = None, bottom_pt: float | None = None, left_pt: float | None = None, header_pt: float | None = None, footer_pt: float | None = None, gutter_pt: float | None = None)[source]

Bases: BaseModel

Represents the margins of a document section.

Example

The following is an example of a section properties element with margins:

<w:sectPr>
    <w:pgMar w:top="720" w:right="720" w:bottom="720" w:left="720"
             w:header="720" w:footer="720" w:gutter="0"/>
</w:sectPr>
bottom_pt: float | None
footer_pt: float | None
gutter_pt: float | None
header_pt: float | None
left_pt: float | None
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'bottom_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The bottom margin in points.'), 'footer_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The footer margin in points.'), 'gutter_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The gutter margin in points.'), 'header_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The header margin in points.'), 'left_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The left margin in points.'), 'right_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The right margin in points.'), 'top_pt': FieldInfo(annotation=Union[float, NoneType], required=False, default=None, description='The top margin in points.')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

right_pt: float | None
top_pt: float | None
class docx_parser_converter.docx_parsers.models.document_models.DocumentSchema(*, elements: List[Paragraph | Table], doc_margins: DocMargins | None = None)[source]

Bases: BaseModel

Represents the overall structure of a document, including paragraphs and tables.

Example

The following is an example of a document schema structure:

<w:document>
    <w:body>
        <w:p>
            <w:pPr>
                <w:pStyle w:val="Heading1"/>
            </w:pPr>
            <w:r>
                <w:t>Example text</w:t>
            </w:r>
        </w:p>
        <w:tbl>
            <!-- Table elements here -->
        </w:tbl>
        <w:sectPr>
            <w:pgMar w:top="720" w:right="720" w:bottom="720" w:left="720"
                     w:header="720" w:footer="720" w:gutter="0"/>
        </w:sectPr>
    </w:body>
</w:document>
doc_margins: DocMargins | None
elements: List[Paragraph | Table]
model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields: ClassVar[dict[str, FieldInfo]] = {'doc_margins': FieldInfo(annotation=Union[DocMargins, NoneType], required=False, default=None, description='The margins of the document.'), 'elements': FieldInfo(annotation=List[Union[Paragraph, Table]], required=True, description='The list of document elements (paragraphs and tables).')}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.