Comment constructor
Contents
[
Hide
]Comment(doc)
Initializes a new instance of the Comment class.
def __init__(self, doc: aspose.words.DocumentBase):
...
Parameter | Type | Description |
---|---|---|
doc | DocumentBase | The owner document. |
Remarks
When Comment is created, it belongs to the specified document, but is not
yet part of the document and Node.parent_node is None
.
To append Comment to the document use CompositeNode.insert_after() or CompositeNode.insert_before() on the paragraph where you want the comment inserted.
After creating a comment, don’t forget to set its Comment.author, Comment.initial and Comment.date_time properties.
Comment(doc, author, initial, date_time)
Initializes a new instance of the Comment class.
def __init__(self, doc: aspose.words.DocumentBase, author: str, initial: str, date_time: datetime.datetime):
...
Parameter | Type | Description |
---|---|---|
doc | DocumentBase | The owner document. |
author | str | The author name for the comment. Cannot be None . |
initial | str | The author initials for the comment. Cannot be None . |
date_time | datetime.datetime | The date and time for the comment. |
Examples
Shows how to add a comment to a paragraph.
doc = aw.Document()
builder = aw.DocumentBuilder(doc)
builder.write('Hello world!')
comment = aw.Comment(doc, 'John Doe', 'JD', date.today())
builder.current_paragraph.append_child(comment)
builder.move_to(comment.append_child(aw.Paragraph(doc)))
builder.write('Comment text.')
self.assertEqual(date.today(), comment.date_time.date())
# In Microsoft Word, we can right-click this comment in the document body to edit it, or reply to it.
doc.save(ARTIFACTS_DIR + 'InlineStory.add_comment.docx')
See Also
- module aspose.words
- class Comment