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

PropertiesPropertiesPropertiesProperties
X`floatNone`Properties
Y`floatNone`Properties
Width`floatNone`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

PropertiesProperties
ParentNode包含的 Page
DocumentDocument

Properties

Accept(visitor)

outline.Accept(visitor: DocumentVisitor) -> None

Properties VisitOutlineStart(outline) 在访问者上,然后递归访问每个子节点 OutlineElement,,然后 VisitOutlineEnd(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}")

遍历大纲中的大纲元素

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 是…中的叶子容器 Outline.。它包含诸如…的内容节点 RichText, Image, Table,,以及 AttachedFile.。嵌套通过…表达 IndentLevel 而不是实际的树深度。.


Properties

PropertiesPropertiesPropertiesProperties
IndentLevelintProperties大纲中的嵌套深度(0 = 最外层)
NumberList`NumberListNone`Properties
Tagslist[NoteTag]Properties附加到此元素的 OneNote 标签

继承自 CompositeNode

属性 / 方法Properties
FirstChild第一个直接内容子节点
LastChild最后一个直接内容子节点
AppendChildLast(node)追加内容节点
GetChildNodes(Type)在子树上递归搜索
for child in elem遍历直接子节点

继承自 Node

PropertiesProperties
ParentNode包含的 Outline
Document根节点 Document

Properties

Accept(visitor)

elem.Accept(visitor: DocumentVisitor) -> None

Properties VisitOutlineElementStart(elem),,递归访问子节点,然后 VisitOutlineElementEnd(elem).


使用示例

从大纲元素中提取纯文本

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

查找带标签的大纲元素

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

以编程方式构建大纲

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 安全性

NumberListNone 用于不属于列表的元素。. Tags 始终是一个列表(可能为空)。. IndentLevel 始终是一个 int (默认 0)。.


另见

 中文