Outline / OutlineElement — Aspose.Note FOSS for Python API Reference

คลาส: Outline

Properties: aspose.note Properties: from aspose.note import Outline Properties: CompositeNode

Outline เป็นคอนเทนเนอร์ตำแหน่งที่วางโดยตรงบน Page. มันมีพิกัด X/Y และความกว้างที่อธิบายว่าบล็อกเนื้อหาตั้งอยู่บนผ้าใบของหน้าอย่างไร ลูกโดยตรงของมันคือ OutlineElement โหนด.


Properties

PropertiesPropertiesPropertiesProperties
X`floatNone`Properties
Y`floatNone`Properties
Width`floatNone`Properties

สืบทอดจาก CompositeNode

คุณสมบัติ / วิธีProperties
FirstChildลูกโดยตรงแรก OutlineElement โหนด, หรือ None
LastChildลูกโดยตรงสุดท้าย OutlineElement โหนด, หรือ None
AppendChildLast(node)ต่อท้าย OutlineElement ที่ส่วนท้าย
AppendChildFirst(node)ต่อหน้ OutlineElement
InsertChild(index, node)แทรกในตำแหน่งที่กำหนด
RemoveChild(node)ลบโหนดลูก
GetChildNodes(Type)การค้นหาแบบลึก‑แรกแบบเรียกซ้ำที่คืนค่าทุกบุตรหลานของประเภทที่ระบุ
for child in outlineวนซ้ำลูกโดยตรง

สืบทอดจาก Node

PropertiesProperties
ParentNodeส่วนที่บรรจุ Page
Documentราก Document

Properties

Accept(visitor)

outline.Accept(visitor: DocumentVisitor) -> None

Properties VisitOutlineStart(outline) บนผู้เยี่ยมชม, จากนั้นทำการเยี่ยมชมแต่ละลูกแบบเรียกซ้ำ OutlineElement, จากนั้น VisitOutlineEnd(outline).


ตัวอย่างการใช้งาน

รวบรวม Outline ทั้งหมดบนหน้า

from aspose.note import Document, Page, Outline

doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
    for outline in page.GetChildNodes(Outline):
        print(f"Outline at X={outline.X}, Y={outline.Y}, Width={outline.Width}")

เดินผ่านองค์ประกอบ Outline ภายใน Outline

from aspose.note import Document, Outline, OutlineElement, RichText

doc = Document("MyNotes.one")
for outline in doc.GetChildNodes(Outline):
    for elem in outline.GetChildNodes(OutlineElement):
        for rt in elem.GetChildNodes(RichText):
            print(rt.Text)

คลาส: OutlineElement

Properties: aspose.note Properties: from aspose.note import OutlineElement Properties: CompositeNode

OutlineElement เป็นคอนเทนเนอร์ leaf ภายใน Outline. มันเก็บโหนดเนื้อหาเช่น RichText, Image, Table, และ AttachedFile. การซ้อนกันถูกแสดงผ่าน IndentLevel แทนที่จะเป็นความลึกของต้นไม้จริง.


Properties

PropertiesPropertiesPropertiesProperties
IndentLevelintPropertiesความลึกของการซ้อนกันภายในโครงร่าง (0 = ชั้นนอกสุด)
NumberList`NumberListNone`Properties
Tagslist[NoteTag]Propertiesแท็ก OneNote ที่แนบกับองค์ประกอบนี้

สืบทอดจาก CompositeNode

คุณสมบัติ / วิธีการProperties
FirstChildลูกเนื้อหาโดยตรงแรก
LastChildลูกเนื้อหาโดยตรงสุดท้าย
AppendChildLast(node)เพิ่มโหนดเนื้อหา
GetChildNodes(Type)การค้นหาแบบเรียกซ้ำบนต้นไม้ย่อย
for child in elemวนซ้ำลูกโดยตรง

สืบทอดจาก Node

PropertiesProperties
ParentNodeส่วนที่บรรจุ Outline
Documentราก Document

Properties

Accept(visitor)

elem.Accept(visitor: DocumentVisitor) -> None

Properties VisitOutlineElementStart(elem), เยี่ยมชมลูกแบบเรียกซ้ำ, จากนั้น VisitOutlineElementEnd(elem).


ตัวอย่างการใช้งาน

สกัดข้อความธรรมดาจากองค์ประกอบ Outline

from aspose.note import Document, OutlineElement, RichText

doc = Document("MyNotes.one")
for elem in doc.GetChildNodes(OutlineElement):
    for rt in elem.GetChildNodes(RichText):
        if rt.Text.strip():
            print(f"  [indent={elem.IndentLevel}] {rt.Text}")

ค้นหารายการในรายการ

from aspose.note import Document, OutlineElement, RichText

doc = Document("MyNotes.one")
for elem in doc.GetChildNodes(OutlineElement):
    if elem.NumberList is not None:
        numbered = elem.NumberList.IsNumbered
        label = "ordered" if numbered else "bulleted"
        for rt in elem.GetChildNodes(RichText):
            print(f"  [{label}] {rt.Text}")

ค้นหาองค์ประกอบ Outline ที่มีแท็ก

from aspose.note import Document, OutlineElement, RichText

doc = Document("MyNotes.one")
for elem in doc.GetChildNodes(OutlineElement):
    if elem.Tags:
        labels = [t.label for t in elem.Tags if t.label]
        for rt in elem.GetChildNodes(RichText):
            print(f"Tags: {labels}  Text: {rt.Text.strip()!r}")

สร้าง Outline อย่างโปรแกรมมิ่ง

from aspose.note import Document, Page, Outline, OutlineElement, RichText, SaveFormat

doc = Document()
page = doc.AppendChildLast(Page())

outline = page.AppendChildLast(Outline())

elem = outline.AppendChildLast(OutlineElement())
rt = elem.AppendChildLast(RichText())
rt.Append("Hello from aspose-note")

doc.Save("output.pdf", SaveFormat.Pdf)

ความปลอดภัยจาก None

NumberList คือ None สำหรับองค์ประกอบที่ไม่ได้เป็นส่วนหนึ่งของรายการ. Tags มักจะเป็นรายการเสมอ (อาจว่างเปล่า). IndentLevel มักจะเป็น int (ค่าเริ่มต้น 0).


ดูเพิ่มเติม

  • Properties: พาเรนท์ของ Outline
  • RichText: เนื้อหาหลักภายใน OutlineElement
  • Properties: เนื้อหาแบบตารางภายใน OutlineElement
  • NumberList: เมตาดาต้าการจัดรูปแบบรายการ
  • NoteTag: แท็กบนองค์ประกอบโครงร่าง
  • DocumentVisitor: การท่องผ่าน Visitor
 ภาษาไทย