Python में OneNote टैग की जांच कैसे करें
OneNote उपयोगकर्ताओं को रंगीन टैग के साथ सामग्री नोट करने की अनुमति देता है: सितारे, चेकबॉक्स, महत्वपूर्ण झंडे और कस्टम लेबल. Aspose.Nota FOSS for Python इन नोटों को प्रस्तुत करता है जैसे कि NoteTag वस्तुओं पर RichText, Image, AttachedFile,और Table अपने नोड्स के माध्यम से .Tags इस गाइड में दिखाया गया है कि उन्हें कैसे पढ़ना है।.
कदम-दर-चरण गाइड
चरण 1: Python के लिए Aspose.Note FOSS स्थापित करें
pip install aspose-noteचरण 2: .1 फ़ाइल लोड करें
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)नोटबुक संपत्ति संदर्भ
| संपत्ति | प्रकार | विवरण |
|---|---|---|
Icon | `int | None` |
Label | `str | None` |
FontColor | `int | None` |
Highlight | `int | None` |
CreationTime | `datetime | None` |
CompletedTime | `datetime | None` |
Status | TagStatus | TagStatus.Completed यदि पूरा हो जाता है तो अन्यथा TagStatus.Open |
फ़िल्टर पूरा vs पेंडिंग टैग
टैग जो चेक किए गए हैं (जैसे " करने के लिए" चेकिंग बॉक्स) एक गैर-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.CreateYellowStar() एक टैग नोड बनाता है जिसे आप नए सामग्री में जोड़ सकते हैं:
from aspose.note import NoteTag
tag = NoteTag.CreateYellowStar()
print(f"Created tag: Icon={tag.Icon} Label={tag.Label!r}")स्मृति में रचना एपीआई संगतता के लिए उपयोगी है. क्योंकि लिखने के बाद वापस
.oneसमर्थन नहीं किया गया है, बनाए गए टैग फ़ाइल के लिए स्थायी नहीं हो सकते हैं।.
सामान्य मुद्दे
कोई टैग नहीं मिला (डॉक खाली टैब सूची वापस करता है): सब नहीं .one फ़ाइलों में टैग होते हैं. यह सुनिश्चित करें कि स्रोत दस्तावेज़ में कोड को हल करने से पहले Microsoft OneNote में दिखाई देने वाले टैब हैं।.
tag.Label एक खाली पंक्ति है: कुछ टैग आकारों में फ़ाइल मेटाडेटा में कोई पाठ लेबल नहीं है. उपयोग करें tag.Icon टैग प्रकार को प्रोग्राम के रूप में पहचानने के लिए।.
संबंधित संसाधन: