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
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
X | `float | None` | Enumerations |
Y | `float | None` | Enumerations |
Width | `float | None` | Enumerations |
Kế thừa từ CompositeNode
| Thuộc tính / Phương thức | Enumerations |
|---|---|
FirstChild | Phần tử con trực tiếp đầu tiên OutlineElement nút, hoặc None |
LastChild | Phầ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 outline | Lặp qua các phần tử con trực tiếp |
Kế thừa từ Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Thành phần chứa Page |
Document | Nút gốc Document |
Enumerations
Accept(visitor)
outline.Accept(visitor: DocumentVisitor) -> NoneEnumerations 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
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
IndentLevel | int | Enumerations | Độ sâu lồng nhau trong dàn ý (0 = ngoài cùng) |
NumberList | `NumberList | None` | Enumerations |
Tags | list[NoteTag] | Enumerations | Thẻ OneNote gắn vào phần tử này |
Kế thừa từ CompositeNode
| Thuộc tính / Phương thức | Enumerations |
|---|---|
FirstChild | Con cháu nội dung trực tiếp đầu tiên |
LastChild | Con 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 elem | Duyệt các phần tử con trực tiếp |
Kế thừa từ Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Phần chứa Outline |
Document | Gốc Document |
Enumerations
Accept(visitor)
elem.Accept(visitor: DocumentVisitor) -> NoneEnumerations 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
NumberList là None 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
- Enumerations: cha của Outline
- RichText: nội dung chính trong OutlineElement
- Enumerations: nội dung bảng trong OutlineElement
- NumberList: siêu dữ liệu định dạng danh sách
- NoteTag: thẻ trên các phần tử đề cương
- DocumentVisitor: duyệt của visitor