AttachedFile — Aspose.Note FOSS for Python API Reference
클래스: AttachedFile
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import AttachedFile ImageRenderOptions: CompositeNode
AttachedFile OneNote 섹션 내부에 삽입된 binary file을 나타냅니다. 이것은 …의 하위 항목입니다. OutlineElement. 원시 파일 데이터는 다음을 통해 제공됩니다 Bytes 속성; 원본 파일 이름은 여기 있습니다 FileName. OneNote 태그가 첨부 파일에 연결되어 다음을 통해 노출됩니다 Tags.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
FileName | `str | None` | ImageRenderOptions |
Bytes | bytes | ImageRenderOptions | 첨부 파일의 원시 바이너리 내용입니다. 기본값은 b"" 첨부 파일 데이터를 읽을 수 없을 때. |
Tags | list[NoteTag] | ImageRenderOptions | OneNote 태그가 이 파일 노드에 첨부되었습니다. |
CompositeNode / Node에서 상속됨
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FirstChild | `Node | None` |
LastChild | `Node | None` |
ParentNode | `Node | None` |
Document | `Document | None` |
ImageRenderOptions
- 읽기 전용 콘텐츠:
Bytes그리고FileNameMS-ONE 바이너리에서 직접 구문 분석됩니다. v26.3.1에서는 임베드된 파일 데이터를 교체할 API가 없습니다. - ImageRenderOptions: 포함된 문서를 저장
AttachedFilenodes to PDF는 첨부 메타데이터를 PDF에 삽입하지만, 실제 바이너리 콘텐츠는 PDF 자체에 포함하지 않습니다. - 빈 바이트: 파일 데이터 블록이 소스에 없거나 길이가 0인 경우
.one파일,Bytes반환합니다b"".
사용 예시
모든 첨부 파일을 디스크에 추출하기
import os
from aspose.note import Document, AttachedFile
doc = Document("MyNotes.one")
output_dir = "attachments"
os.makedirs(output_dir, exist_ok=True)
for af in doc.GetChildNodes(AttachedFile):
name = af.FileName or "unnamed_attachment"
dest = os.path.join(output_dir, name)
with open(dest, "wb") as f:
f.write(af.Bytes)
print(f"Saved: {dest} ({len(af.Bytes)} bytes)")첨부 파일을 태그와 함께 나열하기
from aspose.note import Document, AttachedFile
doc = Document("MyNotes.one")
for af in doc.GetChildNodes(AttachedFile):
tag_labels = [t.label for t in af.Tags if t.label]
print(f"{af.FileName!r} tags={tag_labels} size={len(af.Bytes)}B")None 안전성
FileName 일 수 있습니다 None; 파일을 쓸 때 항상 대체 이름을 제공하십시오. Bytes 항상 bytes (절대 None), 하지만 비어 있을 수 있습니다 (b""). Tags 항상 리스트이며 (비어 있을 수 있습니다).
참고
- CompositeNode: 상위 클래스
- NoteTag: 첨부 파일의 태그
- OutlineElement: 용 컨테이너
AttachedFile - 개발자 가이드