NoteTag — Aspose.Note FOSS for Python API Reference
Lớp: NoteTag
Enumerations: aspose.note Enumerations: from aspose.note import NoteTag Enumerations: Node
NoteTag đại diện cho một biểu tượng thẻ OneNote (ngôi sao, hộp kiểm, dấu quan trọng, v.v.) được gắn vào một nút nội dung. Các thẻ xuất hiện trên RichText, Image, AttachedFile, OutlineElement, và Table các nút thông qua .Tags thuộc tính.
Enumerations
Tất cả các thuộc tính đều chỉ đọc và phản ánh các giá trị được phân tích trực tiếp từ định dạng nhị phân MS-ONE.
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
shape | `int | None` | None |
label | `str | None` | None |
text_color | `int | None` | None |
highlight_color | `int | None` | None |
created | `int | None` | None |
completed | `int | None` | None |
Kế thừa từ Node
| Enumerations | Enumerations | Enumerations |
|---|---|---|
ParentNode | `Node | None` |
Document | `Document | None` |
Ghi chú thời gian
created và completed là các dấu thời gian nguyên số thô được phân tích từ định dạng nhị phân MS-ONE. Chúng là không datetime đối tượng. Nếu bạn cần làm việc với chúng dưới dạng ngày giờ Python, hãy tham khảo đặc tả định dạng tệp MS-ONE để biết công thức chuyển đổi.
Phương thức tạo
NoteTag.CreateYellowStar()
tag = NoteTag.CreateYellowStar() -> NoteTagTrả về một đối tượng mới NoteTag với shape=None và label="Yellow Star". Hữu ích khi xây dựng tài liệu một cách lập trình.
Ví dụ sử dụng
Liệt kê tất cả các phần tử có thẻ trong tài liệu
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}")Lọc các thẻ “To Do” chưa hoàn thành
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-Safety
label, shape, text_color, highlight_color, created, và completed có thể đều là None. Hãy kiểm tra trước khi sử dụng. Tags danh sách trên các nút nội dung luôn là danh sách (không bao giờ None), nhưng có thể rỗng.
Xem Thêm
- Enumerations: lớp cơ sở
- RichText: các nút văn bản mang thẻ
- AttachedFile: các nút đính kèm mang thẻ
- Enumerations: các nút hình ảnh mang thẻ
- Hướng dẫn nhà phát triển