NoteTag — Aspose.Note FOSS for Python API Reference

类:NoteTag

Properties: aspose.note Properties: from aspose.note import NoteTag Properties: Node

NoteTag 表示附加到内容节点的 OneNote 标记图标(星形、复选框、重要标记等)。标记出现在 RichText, Image, AttachedFile, OutlineElement,,以及 Table 节点通过它们的 .Tags 属性。.


Properties

所有属性都是只读的,反映直接从 MS-ONE 二进制格式解析的值。.

PropertiesPropertiesPropertiesProperties
shape`intNone`None
label`strNone`None
text_color`intNone`None
highlight_color`intNone`None
created`intNone`None
completed`intNone`None

继承自 Node

PropertiesPropertiesProperties
ParentNode`NodeNone`
Document`DocumentNone`

时间戳说明

createdcompleted 是从 MS-ONE 二进制格式解析得到的原始整数时间戳。它们是 不是 datetime 对象。如果您需要将它们作为 Python 日期时间使用,请查阅 MS-ONE 文件格式规范中的转换公式。.


工厂方法

NoteTag.CreateYellowStar()

tag = NoteTag.CreateYellowStar() -> NoteTag

返回一个新的 NoteTag 带有 shape=Nonelabel="Yellow Star". 在以编程方式构建文档时很有用。.


使用示例

列出文档中所有带标签的元素

from aspose.note import Document, RichText, Image, AttachedFile, OutlineElement

doc = Document("MyNotes.one")

# Tags on RichText
for rt in doc.GetChildNodes(RichText):
    for tag in rt.Tags:
        print(f"RichText tag: label={tag.label!r}  on: {rt.Text.strip()[:40]!r}")

# Tags on Images
for img in doc.GetChildNodes(Image):
    for tag in img.Tags:
        print(f"Image tag: label={tag.label!r}  file={img.FileName!r}")

# Tags on AttachedFiles
for af in doc.GetChildNodes(AttachedFile):
    for tag in af.Tags:
        print(f"Attachment tag: label={tag.label!r}  file={af.FileName!r}")

过滤未完成的 “To Do” 标签

from aspose.note import Document, RichText

doc = Document("MyNotes.one")
for rt in doc.GetChildNodes(RichText):
    for tag in rt.Tags:
        if tag.label and "to do" in tag.label.lower() and tag.completed is None:
            print(f"Incomplete TODO: {rt.Text.strip()!r}")

None 安全性

label, shape, text_color, highlight_color, created,,并且 completed 都可以是 None. 使用前请进行检查。. Tags 内容节点上的列表始终是列表(永不 None),但可能为空。.


另见

 中文