Paper Office
paper-docxAPI referenceoxml.text.paragraph

CT_P

paper-docx 0.2.0 API reference

<w:p> element, containing the properties and text for a paragraph.

Attributes

add_r

attributeadd_rCallable[[], CT_R]

alignment

attributealignmentWD_PARAGRAPH_ALIGNMENT | None

The value of the <w:jc> grandchild element or None if not present.

get_or_add_pPr

attributeget_or_add_pPrCallable[[], CT_PPr]
attributehyperlink
= ZeroOrMore('w:hyperlink')
attributehyperlink_lstList[CT_Hyperlink]

inner_content_elements

attributeinner_content_elementsList[CT_R | CT_Hyperlink]

Run and hyperlink children of the w:p element, in document order.

lastRenderedPageBreaks

attributelastRenderedPageBreaksList[CT_LastRenderedPageBreak]

All w:lastRenderedPageBreak descendants of this paragraph.

Rendered page-breaks commonly occur in a run but can also occur in a run inside a hyperlink. This returns both.

pPr

attributepPrCT_PPr | None
= ZeroOrOne('w:pPr')

r

attributer
= ZeroOrMore('w:r')

r_lst

attributer_lstList[CT_R]

style

attributestylestr | None

String contained in w:val attribute of ./w:pPr/w:pStyle grandchild.

None if not present.

text

attributetext

The textual content of this paragraph.

Inner-content child elements like w:r and w:hyperlink are translated to their text equivalent.

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_p_before

funcadd_p_before() -> CT_P

Return a new <w:p> element inserted directly prior to this one.

Returns

docx.oxml.text.paragraph.CT_P

clear_content

funcclear_content()

Remove all child elements, except the <w:pPr> element if present.

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

insert_element_before

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

remove_all

funcremove_all(*tagnames: str) -> None

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

paramtagnamesstr
= ()

Returns

None

set_sectPr

funcset_sectPr(sectPr: CT_SectPr)

Unconditionally replace or add sectPr as grandchild in correct sequence.

paramsectPrCT_SectPr

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