AttachedFile — Aspose.Note FOSS for Python API Reference
Clasa: AttachedFile
ImageRenderOptions: aspose.note ImageRenderOptions: from aspose.note import AttachedFile ImageRenderOptions: CompositeNode
AttachedFile reprezintă un fișier binar care a fost încorporat într-o secțiune OneNote. Este un copil al OutlineElement. Bytes proprietate; numele original al fișierului este în FileName. Etichetele OneNote atașate la atașament sunt expuse prin Tags.
ImageRenderOptions
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|---|
FileName | `str | None` | ImageRenderOptions |
Bytes | bytes | ImageRenderOptions | Conținut binar brut al fișierului atașat. Implicit este b"" când datele atașamentului nu au putut fi citite. |
Tags | list[NoteTag] | ImageRenderOptions | Etichetele OneNote atașate acestui nod de fișier. |
Moștenit de la CompositeNode / Node
| ImageRenderOptions | ImageRenderOptions | ImageRenderOptions |
|---|---|---|
FirstChild | `Node | None` |
LastChild | `Node | None` |
ParentNode | `Node | None` |
Document | `Document | None` |
ImageRenderOptions
- Conținut doar în citire:
BytesșiFileNamesunt analizate direct din binarul MS-ONE. Nu există nicio API pentru a înlocui datele fișierului încorporat în v26.3.1. - ImageRenderOptions: Salvarea unui document care conține
AttachedFilenodurile în PDF încorporează metadatele atașamentului, dar nu conținutul binar în PDF-ul propriu-zis. - Octeți goi: Dacă blocul de date al fișierului lipsește sau are lungime zero în sursă
.onefișier,Bytesreturneazăb"".
Exemplu de utilizare
Extrage toate atașamentele pe disc
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)")Listează atașamentele cu etichetele lor
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")Siguranță None
FileName poate fi None; furnizați întotdeauna un nume de rezervă când scrieți fișiere. Bytes este întotdeauna bytes (niciodată None), dar poate fi gol (b""). Tags este întotdeauna o listă (poate fi goală).
Vezi și
- CompositeNode: clasă părinte
- NoteTag: etichete pe un atașament
- OutlineElement: container pentru
AttachedFile - Ghid pentru dezvoltatori