Paper Office
paper-docxAPI referencecomments

Comment

paper-docx 0.2.0 API reference

Proxy for a single comment in the document.

Reads author, initials, date and body content, and adds paragraphs or tables. Every mutation revalidates that the comment is still live first, so a proxy whose part was removed or replaced refuses instead of writing into a detached tree.

Comment(comment_elm: CT_Comment, comments_part: CommentsPart)

Attributes

author

attributeauthorstr

Read/write. The recorded author of this comment.

This field is required but can be set to the empty string.

comment_id

attributecomment_idint

The unique identifier of this comment.

initials

attributeinitialsstr | None

Read/write. The recorded initials of the comment author.

This attribute is optional in the XML, returns None if not set. Assigning None removes any existing initials from the XML.

paragraphs

attributeparagraphs

A list containing the paragraphs in this container, in document order.

Read-only.

part

attributepartStoryPart

The package part containing this object.

tables

attributetables

A list containing the tables in this container, in document order.

Read-only.

text

attributetextstr

The text content of this comment as a string.

Only content in paragraphs is included and of course all emphasis and styling is stripped.

Paragraph boundaries are indicated with a newline ("\\n")

timestamp

attributetimestampdt.datetime | None

The date and time this comment was authored.

This attribute is optional in the XML, returns None if not set.

Functions

add_paragraph

funcadd_paragraph(text: str = '', style: str | ParagraphStyle | None = None) -> Paragraph

Append a paragraph to this comment's body and return it.

Re-keys the comment's commentEx, its replies' paraIdParent, and its commentsIds row onto the new last paragraph, so appending rewrites thread and resolution state. Refuses a protected document, and a proxy whose part was removed or replaced.

paramtextstr
= ''
paramstylestr | ParagraphStyle | None
= None

Returns

docx.text.paragraph.Paragraph

add_table

funcadd_table(rows: int, cols: int, width: Length) -> Table

Append a table to this comment's body and return it.

Re-keys thread and resolution state onto the new last paragraph, as add_paragraph does. Refuses a protected document, and a proxy whose part was removed or replaced.

paramrowsint
paramcolsint
paramwidthLength

Returns

docx.table.Table

iter_inner_content

funciter_inner_content() -> Iterator[Paragraph | Table]

Generate each Paragraph or Table in this container in document order.

Returns

typing.Iterator[docx.text.paragraph.Paragraph | docx.table.Table]

On this page