Python에서 OneNote 태그를 검사하는 방법
OneNote 사용자는 색상 태그가있는 콘텐츠를 기록 할 수 있습니다 : 별, 체크 상자, 중요한 깃발 및 맞춤 레이블. Aspose.Nota FOSS for Python은 이러한 기록을 설명합니다. NoteTag 객체에 대하여 RichText, Image, AttachedFile,그리고, 그리고 Table 그들의 둥지를 통해서 .Tags 이 가이드는 어떻게 읽을 수 있는지 보여줍니다.
단계별 가이드
단계 1: Python을 위한 Aspose.Note FOSS 설치하기
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)부동산 참조
| 부동산 | 유형 | 설명 |
|---|---|---|
Icon | `int | None` |
Label | `str | None` |
FontColor | `int | None` |
Highlight | `int | None` |
CreationTime | `datetime | None` |
CompletedTime | `datetime | None` |
Status | TagStatus | TagStatus.Completed 만약 완성되면, 다른 TagStatus.Open |
Filter 완성 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}")메모리에서 노트 태그를 만드는 방법 (In-Memory)
공장 방법 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 빈 줄이 있는 것 같아요.: 일부 태그 형식에는 파일 메타 데이터에 텍스트 라벨이 없습니다. tag.Icon 타이틀 유형을 프로그래밍적으로 식별하십시오.
관련 자원 :