section
section
¶
Section-related custom element classes.
CT_PageBorders
¶
Bases: _CT_BordersBase
w:pgBorders element, the border drawn around the pages of a section.
Only four edges, unlike w:pBdr. The three attributes have no CT_Border
counterpart and belong to the container: where the border is measured from, which
pages it appears on, and whether it is drawn in front of or behind the page content.
The schema gives the top and bottom edges the CT_TopPageBorder and
CT_BottomPageBorder types, which add attributes naming a decorative border image.
Those are not modelled; the edges arrive as CT_Border like every other edge tag,
which covers the line style, colour, width and spacing that make up an ordinary
page border.
CT_HdrFtr
¶
Bases: BaseOxmlElement
w:hdr and w:ftr, the root element for header and footer part respectively.
CT_HdrFtrRef
¶
CT_Column
¶
CT_Columns
¶
Bases: BaseOxmlElement
w:cols element, the multi-column layout of a section.
w:col children appear only when the columns are of unequal width; the common
equal-width case is described entirely by the attributes here.
CT_PageMar
¶
CT_PageSz
¶
CT_SectPr
¶
Bases: BaseOxmlElement
w:sectPr element, the container element for section properties.
bidi_val
property
writable
¶
Value of ./w:bidi/@w:val, or None if the element is absent.
textDirection_val
property
writable
¶
textDirection_val: WD_TEXT_DIRECTION | None
Value of ./w:textDirection/@w:val, or None if the element is absent.
bottom_margin
property
writable
¶
bottom_margin: Length | None
Value of the w:bottom attr of <w:pgMar> child element, as Length.
None when either the element or the attribute is not present.
footer
property
writable
¶
footer: Length | None
Distance from bottom edge of page to bottom edge of the footer.
This is the value of the w:footer attribute in the w:pgMar child element,
as a Length object, or None if either the element or the attribute is not
present.
gutter
property
writable
¶
gutter: Length | None
The value of the w:gutter attribute in the <w:pgMar> child element,
as a Length object, or None if either the element or the attribute is not
present.
header
property
writable
¶
header: Length | None
Distance from top edge of page to top edge of header.
This value comes from the w:header attribute on the w:pgMar child element.
None if either the element or the attribute is not present.
left_margin
property
writable
¶
left_margin: Length | None
The value of the w:left attribute in the <w:pgMar> child element, as
a Length object, or None if either the element or the attribute is not
present.
orientation
property
writable
¶
orientation: WD_ORIENTATION
WD_ORIENTATION member indicating page-orientation for this section.
This is the value of the orient attribute on the w:pgSz child, or
WD_ORIENTATION.PORTRAIT if not present.
page_height
property
writable
¶
page_height: Length | None
Value in EMU of the h attribute of the w:pgSz child element.
None if not present.
page_width
property
writable
¶
page_width: Length | None
Value in EMU of the w attribute of the <w:pgSz> child element.
None if not present.
preceding_sectPr
property
¶
preceding_sectPr: CT_SectPr | None
SectPr immediately preceding this one or None if this is the first.
right_margin
property
writable
¶
right_margin: Length | None
The value of the w:right attribute in the <w:pgMar> child element, as
a Length object, or None if either the element or the attribute is not
present.
start_type
property
writable
¶
start_type: WD_SECTION_START
The member of the WD_SECTION_START enumeration corresponding to the value
of the val attribute of the <w:type> child element, or
WD_SECTION_START.NEW_PAGE if not present.
titlePg_val
property
writable
¶
Value of w:titlePg/@val or False if ./w:titlePg is not present.
top_margin
property
writable
¶
top_margin: Length | None
The value of the w:top attribute in the <w:pgMar> child element, as a
Length object, or None if either the element or the attribute is not
present.
add_footerReference
¶
add_footerReference(
type_: WD_HEADER_FOOTER, rId: str
) -> CT_HdrFtrRef
Return newly added CT_HdrFtrRef element of type_ with rId.
The element tag is w:footerReference.
Source code in src/docx/oxml/section.py
add_headerReference
¶
add_headerReference(
type_: WD_HEADER_FOOTER, rId: str
) -> CT_HdrFtrRef
Return newly added CT_HdrFtrRef element of type_ with rId.
The element tag is w:headerReference.
Source code in src/docx/oxml/section.py
clone
¶
clone() -> CT_SectPr
Return an exact duplicate of this <w:sectPr> element tree suitable for
use in adding a section break.
All rsid* attributes are removed from the root <w:sectPr> element.
Source code in src/docx/oxml/section.py
get_footerReference
¶
get_footerReference(
type_: WD_HEADER_FOOTER,
) -> CT_HdrFtrRef | None
Return footerReference element of type_ or None if not present.
Source code in src/docx/oxml/section.py
get_headerReference
¶
get_headerReference(
type_: WD_HEADER_FOOTER,
) -> CT_HdrFtrRef | None
Return headerReference element of type_ or None if not present.
Source code in src/docx/oxml/section.py
iter_inner_content
¶
Generate all w:p and w:tbl elements in this section.
Elements appear in document order. Elements shaded by nesting in a w:ins or
other "wrapper" element will not be included.
Source code in src/docx/oxml/section.py
remove_footerReference
¶
Return rId of w:footerReference child of type_ after removing it.
Source code in src/docx/oxml/section.py
remove_headerReference
¶
Return rId of w:headerReference child of type_ after removing it.
Source code in src/docx/oxml/section.py
CT_SectType
¶
_SectBlockElementIterator
¶
_SectBlockElementIterator(sectPr: CT_SectPr)
Generates the block-item XML elements in a section.
A block-item element is a CT_P (paragraph) or a CT_Tbl (table).