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

PropertyTypeDefaultDescription
Iconint | NoneNoneNumeric shape identifier for the tag icon as defined by the MS-ONE spec. None when absent.
Labelstr | NoneNoneHuman-readable display label (e.g. "Yellow Star", "Important", "To Do"). None when absent.
FontColorint | NoneNoneTag text colour as a packed ARGB integer.
Highlightint | NoneNoneTag highlight colour as a packed ARGB integer.
CreationTimedatetime | NoneNoneWhen the tag was created. None when absent from file.
CompletedTimedatetime | NoneNoneWhen the tag was completed. None if the tag has not been completed.
StatusTagStatusderivedTagStatus.Completed if CompletedTime is set, otherwise TagStatus.Open.

Factory Methods

NoteTag.CreateYellowStar()

tag = NoteTag.CreateYellowStar(label=None) -> NoteTag

Returns 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