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

EnumerationsEnumerationsEnumerationsEnumerations
X`floatNone`Enumerations
Y`floatNone`Enumerations
Width`floatNone`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

EnumerationsEnumerations
ParentNodeКонтейнер Page
DocumentКорінь Document

Enumerations

Accept(visitor)

outline.Accept(visitor: DocumentVisitor) -> None

Enumerations 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

EnumerationsEnumerationsEnumerationsEnumerations
IndentLevelintEnumerationsГлибина вкладеності в межах контуру (0 = найзовнішня)
NumberList`NumberListNone`Enumerations
Tagslist[NoteTag]EnumerationsТеги OneNote, прикріплені до цього елемента

Успадковано від CompositeNode

Властивість / МетодEnumerations
FirstChildПерший прямий дочірній елемент вмісту
LastChildОстанній прямий дочірній елемент вмісту
AppendChildLast(node)Додати вузол вмісту
GetChildNodes(Type)Рекурсивний пошук по піддереву
for child in elemПеребрати прямі дочірні елементи

Успадковано від Node

EnumerationsEnumerations
ParentNodeКонтейнер Outline
DocumentКорінь Document

Enumerations

Accept(visitor)

elem.Accept(visitor: DocumentVisitor) -> None

Enumerations 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).


Див. також

 Українська