NoteTag — Aspose.Note FOSS for Python API Reference
Class: NoteTag
Package: aspose.note
Import: from aspose.note import NoteTag
NoteTag represents a OneNote tag icon (star, checkbox, important marker, etc.) that is attached to a content node. Tags appear on RichText, Image, AttachedFile, and Table nodes via their .Tags property. OutlineElement does not have a .Tags property.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
Icon | int | None | None | Numeric shape identifier for the tag icon as defined by the MS-ONE spec. None when absent. |
Label | str | None | None | Human-readable display label (e.g. "Yellow Star", "Important", "To Do"). None when absent. |
FontColor | int | None | None | Tag text colour as a packed ARGB integer. |
Highlight | int | None | None | Tag highlight colour as a packed ARGB integer. |
CreationTime | datetime | None | None | When the tag was created. None when absent from file. |
CompletedTime | datetime | None | None | When the tag was completed. None if the tag has not been completed. |
Status | TagStatus | derived | TagStatus.Completed if CompletedTime is set, otherwise TagStatus.Open. |
Factory Methods
NoteTag.CreateYellowStar()
tag = NoteTag.CreateYellowStar(label=None) -> NoteTagReturns a new NoteTag with Label="Yellow Star" and Icon=13. Useful when constructing documents programmatically.
Usage Example
List all tagged elements in a document
from aspose.note import Document, RichText, Image, AttachedFile
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}")Filter for incomplete “To Do” tags
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.CompletedTime is None:
print(f"Incomplete TODO: {rt.Text.strip()!r}")None-Safety
Label, Icon, FontColor, Highlight, CreationTime, and CompletedTime can all be None. Guard before use. Tags lists on content nodes are always lists (never None), but may be empty.
See Also
- RichText: text nodes that carry tags
- AttachedFile: attachment nodes that carry tags
- Image: image nodes that carry tags
- Developer Guide