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
| Properties | Properties | Properties | Properties |
|---|---|---|---|
X | `float | None` | Properties |
Y | `float | None` | Properties |
Width | `float | None` | 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
| Properties | Properties |
|---|---|
ParentNode | ส่วนที่บรรจุ Page |
Document | ราก Document |
Properties
Accept(visitor)
outline.Accept(visitor: DocumentVisitor) -> NoneProperties 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
| Properties | Properties | Properties | Properties |
|---|---|---|---|
IndentLevel | int | Properties | ความลึกของการซ้อนกันภายในโครงร่าง (0 = ชั้นนอกสุด) |
NumberList | `NumberList | None` | Properties |
Tags | list[NoteTag] | Properties | แท็ก OneNote ที่แนบกับองค์ประกอบนี้ |
สืบทอดจาก CompositeNode
| คุณสมบัติ / วิธีการ | Properties |
|---|---|
FirstChild | ลูกเนื้อหาโดยตรงแรก |
LastChild | ลูกเนื้อหาโดยตรงสุดท้าย |
AppendChildLast(node) | เพิ่มโหนดเนื้อหา |
GetChildNodes(Type) | การค้นหาแบบเรียกซ้ำบนต้นไม้ย่อย |
for child in elem | วนซ้ำลูกโดยตรง |
สืบทอดจาก Node
| Properties | Properties |
|---|---|
ParentNode | ส่วนที่บรรจุ Outline |
Document | ราก Document |
Properties
Accept(visitor)
elem.Accept(visitor: DocumentVisitor) -> NoneProperties 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