docx_parser_converter.docx_parsers.document.margins_parser module
- class docx_parser_converter.docx_parsers.document.margins_parser.MarginsParser[source]
Bases:
objectParses the margin properties of a section in a docx document.
This class contains methods to parse the margin properties from the section properties (sectPr) element of a docx document. The margin properties are essential for understanding the layout of the document.
- static parse(sectPr: Element | None) DocMargins | None[source]
Parses margins from the given section properties XML element.
- Parameters:
sectPr (Optional[etree.Element]) – The section properties XML element. This element can contain margin properties which define the top, right, bottom, left, header, footer, and gutter margins of the section.
- Returns:
The parsed margins, or None if not found.
- Return type:
Optional[DocMargins]
Example
The following is an example of the section properties with margins in a document.xml file:
<w:sectPr> <w:pgMar w:left="1134" w:right="1134" w:gutter="0" w:header="0" w:top="1134" w:footer="0" w:bottom="1134"/> </w:sectPr>