Paper Office
paper-docxAPI referenceoxml.comments

CT_Comments

paper-docx 0.2.0 API reference

w:comments element, the root element for the comments part.

Simply contains a collection of w:comment elements, each representing a single comment. Each contained comment is identified by a unique w:id attribute, used to reference the comment from the document text. The offset of the comment in this collection is arbitrary; it is essentially a set implemented as a list.

Attributes

comment

attributecomment
= ZeroOrMore('w:comment')

comment_lst

attributecomment_lstlist[CT_Comment]

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_comment

funcadd_comment() -> CT_Comment

Return newly added w:comment child of this w:comments.

The returned w:comment element is the minimum valid value, having a w:id value unique within the existing comments and the required w:author attribute present but set to the empty string. It's content is limited to a single run containing the necessary annotation reference but no text. Content is added by adding runs to this first paragraph and by adding additional paragraphs as needed.

Returns

docx.oxml.comments.CT_Comment

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_comment_by_id

funcget_comment_by_id(comment_id: int) -> CT_Comment | None

Return the w:comment element identified by comment_id, or None if not found.

paramcomment_idint

Returns

docx.oxml.comments.CT_Comment | 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

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