AttachedFile — Aspose.Note FOSS for Python API Reference
クラス: AttachedFile
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import AttachedFile ImageRenderOptions: CompositeNode
AttachedFile OneNote セクション内に埋め込まれたバイナリ ファイルを表します。これは 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およびFileNameは MS-ONE バイナリから直接解析されます。v26.3.1 では埋め込みファイルデータを置き換える API はありません。. - ImageRenderOptions: 含むドキュメントを保存する
AttachedFileノードを PDF に埋め込むと、添付メタデータは埋め込まれますが、PDF 本体のバイナリコンテンツは埋め込まれません。. - 空のバイト: ソースでファイルデータブロックが欠落しているか長さがゼロの場合
.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 - 開発者ガイド