Python में OneNote टैग्स का निरीक्षण कैसे करें
OneNote उपयोगकर्ताओं को रंगीन टैग के साथ सामग्री पर टिप्पणी करने की अनुमति देता है: सितारे, चेकबॉक्स, महत्वपूर्ण फ़्लैग, और कस्टम लेबल। Aspose.Note FOSS for Python इन एनोटेशनों को as NoteTag ऑब्जेक्ट्स पर RichText, Image, AttachedFile, Table नोड्स उनके माध्यम से .Tags प्रॉपर्टी। यह गाइड दिखाता है कि उन्हें कैसे पढ़ा जाए।.
स्टेप बाय स्टेप गाइड
चरण 1: Aspose.Note FOSS for Python स्थापित करें
pip install aspose-noteचरण 2: .one फ़ाइल लोड करें
from aspose.note import Document
doc = Document("TaggedNotes.one")
print(f"Pages: {len(list(doc))}")चरण 3: RichText नोड्स पर टैग्स खोजें
अधिकांश टैग्स टेक्स्ट ब्लॉक्स से जुड़े होते हैं:
from aspose.note import Document, RichText
doc = Document("TaggedNotes.one")
for rt in doc.GetChildNodes(RichText):
for tag in rt.Tags:
print(f"[RichText] Label={tag.Label!r} Icon={tag.Icon} text={rt.Text.strip()!r}")चरण 4: इमेजेज़ पर टैग्स खोजें
from aspose.note import Document, Image
doc = Document("TaggedNotes.one")
for img in doc.GetChildNodes(Image):
for tag in img.Tags:
print(f"[Image] Label={tag.Label!r} filename={img.FileName!r}")चरण 5: टेबल्स पर टैग्स खोजें
from aspose.note import Document, Table
doc = Document("TaggedNotes.one")
for table in doc.GetChildNodes(Table):
for tag in table.Tags:
print(f"[Table] Label={tag.Label!r} widths={[col.Width for col in table.Columns]}")चरण 6: दस्तावेज़ में सभी टैग्स एकत्र करें
from aspose.note import Document, RichText, Image, Table
doc = Document("TaggedNotes.one")
all_tags = []
for rt in doc.GetChildNodes(RichText):
for tag in rt.Tags:
all_tags.append({"type": "RichText", "Label": tag.Label,
"CompletedTime": tag.CompletedTime, "text": rt.Text.strip()})
for img in doc.GetChildNodes(Image):
for tag in img.Tags:
all_tags.append({"type": "Image", "Label": tag.Label,
"CompletedTime": tag.CompletedTime, "file": img.FileName})
for table in doc.GetChildNodes(Table):
for tag in table.Tags:
all_tags.append({"type": "Table", "Label": tag.Label,
"CompletedTime": tag.CompletedTime})
print(f"Total tagged items: {len(all_tags)}")
for item in all_tags:
print(item)NoteTag प्रॉपर्टी संदर्भ
| प्रॉपर्टी | प्रकार | विवरण |
|---|---|---|
Icon | `int | None` |
Label | `str | None` |
FontColor | `int | None` |
Highlight | `int | None` |
CreationTime | `datetime | None` |
CompletedTime | `datetime | None` |
Status | TagStatus | TagStatus.Completed यदि पूरा हुआ, अन्यथा TagStatus.Open |
पूरा किए गए बनाम लंबित टैग्स को फ़िल्टर करें
जिन टैगों को चेक किया गया है (जैसे “To Do” चेकबॉक्स) उनका non-None CompletedTime फ़ील्ड:
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.CompletedTime 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}")एक NoteTag बनाएं (इन-मेमोरी)
फ़ैक्टरी मेथड NoteTag.CreateYellowStar() एक टैग नोड बनाता है जिसे आप नई सामग्री में‑in-memory संलग्न कर सकते हैं:
from aspose.note import NoteTag
tag = NoteTag.CreateYellowStar()
print(f"Created tag: Icon={tag.Icon} Label={tag.Label!r}")इन‑मेमोरी निर्माण API संगतता के लिए उपयोगी है। चूँकि वापस लिखना है .one समर्थित नहीं है, बनाए गए टैग फ़ाइल में सहेजे नहीं जा सकते।.
सामान्य समस्याएँ
कोई टैग नहीं मिला (दस्तावेज़ खाली टैग सूची लौटाता है): सभी नहीं .one फ़ाइलों में टैग होते हैं। कोड की समस्या निवारण से पहले सत्यापित करें कि स्रोत दस्तावेज़ में Microsoft OneNote में टैग दिखाई दे रहे हैं।.
tag.Label एक खाली स्ट्रिंग है: कुछ टैग आकारों के फ़ाइल मेटाडेटा में टेक्स्ट लेबल नहीं होता। Use tag.Icon टैग प्रकार को प्रोग्रामेटिकली पहचानने के लिए।.
संबंधित संसाधन: