Outline / OutlineElement — Aspose.Note FOSS for Python API Reference
Клас: Outline
Enumerations: aspose.note Enumerations: from aspose.note import Outline Enumerations: CompositeNode
Outline є позиційним контейнером, розташованим безпосередньо на Page. Він містить координати X/Y та ширину, які описують, де блок вмісту розташований на полотні сторінки. Його прямі дочірні елементи – OutlineElement вузлів.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
X | `float | None` | Enumerations |
Y | `float | None` | Enumerations |
Width | `float | None` | Enumerations |
Успадковано від CompositeNode
| Властивість / Метод | Enumerations |
|---|---|
FirstChild | Перший прямий дочірній елемент OutlineElement вузол, або None |
LastChild | Останній прямий дочірній елемент OutlineElement вузол, або None |
AppendChildLast(node) | Додати OutlineElement в кінець |
AppendChildFirst(node) | Додати на початок OutlineElement |
InsertChild(index, node) | Вставити у певну позицію |
RemoveChild(node) | Видалити дочірній вузол |
GetChildNodes(Type) | Рекурсивний пошук у глибину, що повертає всі нащадки заданого типу |
for child in outline | Ітерація безпосередніх дочірніх елементів |
Успадковано від Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Контейнер Page |
Document | Корінь Document |
Enumerations
Accept(visitor)
outline.Accept(visitor: DocumentVisitor) -> NoneEnumerations 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
Enumerations: aspose.note Enumerations: from aspose.note import OutlineElement Enumerations: CompositeNode
OutlineElement є листовим контейнером у Outline. Він містить вузли вмісту, такі як RichText, Image, Table, і AttachedFile. Вкладеність виражається за допомогою IndentLevel замість фактичної глибини дерева.
Enumerations
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
IndentLevel | int | Enumerations | Глибина вкладеності в межах контуру (0 = найзовнішня) |
NumberList | `NumberList | None` | Enumerations |
Tags | list[NoteTag] | Enumerations | Теги OneNote, прикріплені до цього елемента |
Успадковано від CompositeNode
| Властивість / Метод | Enumerations |
|---|---|
FirstChild | Перший прямий дочірній елемент вмісту |
LastChild | Останній прямий дочірній елемент вмісту |
AppendChildLast(node) | Додати вузол вмісту |
GetChildNodes(Type) | Рекурсивний пошук по піддереву |
for child in elem | Перебрати прямі дочірні елементи |
Успадковано від Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Контейнер Outline |
Document | Корінь Document |
Enumerations
Accept(visitor)
elem.Accept(visitor: DocumentVisitor) -> NoneEnumerations 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).
Див. також
- Enumerations: батько Outline
- RichText: основний вміст у OutlineElement
- Enumerations: вміст таблиці у OutlineElement
- NumberList: метадані форматування списку
- NoteTag: теги на елементах плану
- DocumentVisitor: обхід відвідувача