AttachedFile

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

ImageRenderOptionsImageRenderOptionsImageRenderOptionsImageRenderOptions
FileName`strNone`ImageRenderOptions
BytesbytesImageRenderOptionsתוכן בינארי גולמי של הקובץ המצורף. ברירת מחדל היא b"" כאשר לא ניתן היה לקרוא את נתוני הקובץ המצורף.
Tagslist[NoteTag]ImageRenderOptionsתגיות OneNote מצורפות לצומת הקובץ הזה.

יורש מ-CompositeNode / Node

ImageRenderOptionsImageRenderOptionsImageRenderOptions
FirstChild`NodeNone`
LastChild`NodeNone`
ParentNode`NodeNone`
Document`DocumentNone`

ImageRenderOptions

  • תוכן לקריאה בלבד: Bytes ו FileName מפורשים ישירות מהקובץ הבינארי של MS-ONE. אין API להחלפת נתוני הקובץ המוטמע ב‑v26.3.1.
  • ImageRenderOptions: שמירת מסמך שמכיל AttachedFile nodes to 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 תמיד רשימה (עשויה להיות ריקה).


ראה גם

 עברית