How to Inspect OneNote Tags in Python
OneNote lets users annotate content with colored tags — stars, checkboxes, important flags, and custom labels. Aspose.Note FOSS for Python exposes these annotations as NoteTag objects on RichText, Image, Table, and OutlineElement nodes. This guide shows how to read them.
Step-by-Step Guide
NoteTag Property Reference
| Property | Type | Description |
|---|---|---|
shape | — | Tag shape identifier (star, checkbox, arrow, etc.) |
label | str | Human-readable label string (e.g. "Important", "To Do") |
text_color | int | Text color as ARGB integer |
highlight_color | int | Highlight color as ARGB integer |
created | datetime | Timestamp when the tag was applied |
completed | datetime | None | Timestamp when the tag was completed (None if not completed) |
Filter Completed vs Pending Tags
Tags that have been checked off (like “To Do” checkboxes) have a non-None completed field:
from aspose.note import Document, RichText
doc = Document("TaggedNotes.one")
pending, done = [], []
for rt in doc.GetChildNodes(RichText):
for tag in rt.Tags:
item = {"label": tag.label, "text": rt.Text.strip()}
if tag.completed is None:
pending.append(item)
else:
done.append(item)
print(f"Pending: {len(pending)} Done: {len(done)}")
for p in pending:
print(f" [ ] {p['label']}: {p['text']!r}")
for d in done:
print(f" [x] {d['label']}: {d['text']!r}")Create a NoteTag (In-Memory)
The factory method NoteTag.CreateYellowStar() creates a tag node you can attach to new content in-memory:
from aspose.note import NoteTag
tag = NoteTag.CreateYellowStar()
print(f"Created tag: shape={tag.shape} label={tag.label!r}")In-memory creation is useful for API compatibility. Since writing back to
.oneis not supported, created tags cannot be persisted to file.
Common Issues
No tags found — document returns empty Tags lists: Not all .one files contain tags. Verify the source document has tags visible in Microsoft OneNote before troubleshooting the code.
tag.label is an empty string: Some tag shapes do not have a text label in the file metadata. Use tag.shape to identify the tag type programmatically.
Related Resources: