Paper Office
paper-docxAPI referenceoxml.section

CT_SectPr

paper-docx 0.2.0 API reference

w:sectPr element, the container element for section properties.

Attributes

bottom_margin

attributebottom_marginLength | 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.

attributefooterLength | 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.

footerReference

attributefooterReference
= ZeroOrMore('w:footerReference', successors=_tag_seq)

get_or_add_pgMar

attributeget_or_add_pgMarCallable[[], CT_PageMar]

get_or_add_pgSz

attributeget_or_add_pgSzCallable[[], CT_PageSz]

get_or_add_titlePg

attributeget_or_add_titlePgCallable[[], CT_OnOff]

get_or_add_type

attributeget_or_add_typeCallable[[], CT_SectType]

gutter

attributegutterLength | 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.

attributeheaderLength | 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.

headerReference

attributeheaderReference
= ZeroOrMore('w:headerReference', successors=_tag_seq)

left_margin

attributeleft_marginLength | 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

attributeorientationWD_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

attributepage_heightLength | None

Value in EMU of the h attribute of the w:pgSz child element.

None if not present.

page_width

attributepage_widthLength | None

Value in EMU of the w attribute of the <w:pgSz> child element.

None if not present.

pgMar

attributepgMarCT_PageMar | None
= ZeroOrOne('w:pgMar', successors=(_tag_seq[5:]))

pgSz

attributepgSzCT_PageSz | None
= ZeroOrOne('w:pgSz', successors=(_tag_seq[4:]))

preceding_sectPr

attributepreceding_sectPrCT_SectPr | None

SectPr immediately preceding this one or None if this is the first.

right_margin

attributeright_marginLength | 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

attributestart_typeWD_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

attributetitlePgCT_OnOff | None
= ZeroOrOne('w:titlePg', successors=(_tag_seq[14:]))

titlePg_val

attributetitlePg_valbool

Value of w:titlePg/@val or False if ./w:titlePg is not present.

top_margin

attributetop_marginLength | 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.

type

attributetypeCT_SectType | None
= ZeroOrOne('w:type', successors=(_tag_seq[3:]))

xml

attributexmlstr

XML string for this element, suitable for testing purposes.

Pretty printed for readability and without an XML declaration at the top.

Functions

add_footerReference

funcadd_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.

paramtype_WD_HEADER_FOOTER
paramrIdstr

Returns

docx.oxml.section.CT_HdrFtrRef

add_headerReference

funcadd_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.

paramtype_WD_HEADER_FOOTER
paramrIdstr

Returns

docx.oxml.section.CT_HdrFtrRef

clone

funcclone() -> 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.

Returns

docx.oxml.section.CT_SectPr

first_child_found_in

funcfirst_child_found_in(*tagnames: str) -> _Element | None

First child with tag in tagnames, or None if not found.

paramtagnamesstr
= ()

Returns

lxml.etree._Element | None

get_footerReference

funcget_footerReference(type_: WD_HEADER_FOOTER) -> CT_HdrFtrRef | None

Return footerReference element of type_ or None if not present.

paramtype_WD_HEADER_FOOTER

Returns

docx.oxml.section.CT_HdrFtrRef | None

get_headerReference

funcget_headerReference(type_: WD_HEADER_FOOTER) -> CT_HdrFtrRef | None

Return headerReference element of type_ or None if not present.

paramtype_WD_HEADER_FOOTER

Returns

docx.oxml.section.CT_HdrFtrRef | None

insert_element_before

funcinsert_element_before(elm: ElementBase, *tagnames: str)
paramelmElementBase
paramtagnamesstr
= ()

iter_inner_content

funciter_inner_content() -> Iterator[CT_P | CT_Tbl]

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.

Returns

typing.Iterator[docx.oxml.text.paragraph.CT_P | docx.oxml.table.CT_Tbl]

remove_all

funcremove_all(*tagnames: str) -> None

Remove child elements with tagname (e.g. "a:p") in tagnames.

paramtagnamesstr
= ()

Returns

None

remove_footerReference

funcremove_footerReference(type_: WD_HEADER_FOOTER) -> str

Return rId of w:footerReference child of type_ after removing it.

paramtype_WD_HEADER_FOOTER

Returns

str

remove_headerReference

funcremove_headerReference(type_: WD_HEADER_FOOTER)

Return rId of w:headerReference child of type_ after removing it.

paramtype_WD_HEADER_FOOTER

xpath

funcxpath(xpath_str: str) -> Any

Override of lxml _Element.xpath() method.

Provides standard Open XML namespace mapping (nsmap) in centralized location.

paramxpath_strstr

Returns

typing.Any

On this page