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

Lớp: Outline

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

Outline là một container định vị được đặt trực tiếp trên một Page. Nó mang các tọa độ X/Y và chiều rộng mô tả vị trí của khối nội dung trên canvas trang. Các phần tử con trực tiếp của nó là OutlineElement nút.


Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
X`floatNone`Enumerations
Y`floatNone`Enumerations
Width`floatNone`Enumerations

Kế thừa từ CompositeNode

Thuộc tính / Phương thứcEnumerations
FirstChildPhần tử con trực tiếp đầu tiên OutlineElement nút, hoặc None
LastChildPhần tử con trực tiếp cuối cùng OutlineElement nút, hoặc None
AppendChildLast(node)Thêm một OutlineElement vào cuối
AppendChildFirst(node)Thêm một vào đầu OutlineElement
InsertChild(index, node)Chèn vào vị trí cụ thể
RemoveChild(node)Xóa một nút con
GetChildNodes(Type)Tìm kiếm đệ quy theo chiều sâu trả về tất cả các phần tử con của loại đã cho
for child in outlineLặp qua các phần tử con trực tiếp

Kế thừa từ Node

EnumerationsEnumerations
ParentNodeThành phần chứa Page
DocumentNút gốc Document

Enumerations

Accept(visitor)

outline.Accept(visitor: DocumentVisitor) -> None

Enumerations VisitOutlineStart(outline) trên visitor, sau đó đệ quy truy cập mỗi nút con OutlineElement, sau đó VisitOutlineEnd(outline).


Ví dụ sử dụng

Thu thập tất cả các outline trên một trang

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}")

Duyệt các phần tử outline trong một 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)

Lớp: OutlineElement

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

OutlineElement là container lá trong một Outline. Nó chứa các nút nội dung như RichText, Image, Table, và AttachedFile. Độ lồng nhau được biểu thị bằng IndentLevel thay vì độ sâu thực tế của cây.


Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
IndentLevelintEnumerationsĐộ sâu lồng nhau trong dàn ý (0 = ngoài cùng)
NumberList`NumberListNone`Enumerations
Tagslist[NoteTag]EnumerationsThẻ OneNote gắn vào phần tử này

Kế thừa từ CompositeNode

Thuộc tính / Phương thứcEnumerations
FirstChildCon cháu nội dung trực tiếp đầu tiên
LastChildCon cháu nội dung trực tiếp cuối cùng
AppendChildLast(node)Thêm một nút nội dung
GetChildNodes(Type)Tìm kiếm đệ quy trên cây con
for child in elemDuyệt các phần tử con trực tiếp

Kế thừa từ Node

EnumerationsEnumerations
ParentNodePhần chứa Outline
DocumentGốc Document

Enumerations

Accept(visitor)

elem.Accept(visitor: DocumentVisitor) -> None

Enumerations VisitOutlineElementStart(elem), đệ quy thăm các phần tử con, sau đó VisitOutlineElementEnd(elem).


Ví dụ sử dụng

Trích xuất văn bản thuần từ các phần tử 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}")

Tìm các mục danh sách

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}")

Tìm các phần tử outline có thẻ

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}")

Xây dựng một outline bằng chương trình

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-Safety

NumberListNone cho các phần tử không thuộc danh sách. Tags luôn luôn là một danh sách (có thể rỗng). IndentLevel luôn luôn là một int (mặc định 0).


Xem Thêm

 Tiếng Việt