Page — Aspose.Note FOSS for Python API Reference

Class: Page

Package: aspose.note Import: from aspose.note import Page Inherits: CompositeNode

Page represents a single OneNote page within a Document. Pages are the direct children of Document. Each page can contain Outline nodes (which in turn contain OutlineElement and content nodes).


Properties

PropertyTypeAccessDescription
TitleTitle | NoneReadThe page title block; None if the page has no title
Authorstr | NoneReadAuthor string stored in the file metadata
CreationTimedatetime | NoneReadPage creation timestamp
LastModifiedTimedatetime | NoneReadLast modification timestamp
Levelint | NoneReadSub-page indent level; 0 is top-level, 1 is first indent, etc.

Inherited from CompositeNode

Property / MethodDescription
FirstChildFirst direct child node
LastChildLast direct child node
GetChildNodes(Type)Recursive type-filtered search
for child in pageIterate direct children (Outlines)

Inherited from Node

PropertyDescription
ParentNodeThe parent Document
DocumentThe root Document

Methods

Clone(deep=False)

page.Clone(deep: bool = False) -> Page

Returns a copy of the page. deep=False creates a shallow clone with no children.


Accept(visitor)

page.Accept(visitor: DocumentVisitor) -> None

Dispatches VisitPageStart(page) on the visitor, then recursively visits child nodes, then VisitPageEnd(page).


Usage Examples

Iterate all pages

from aspose.note import Document, Page

doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
    title = (
        page.Title.TitleText.Text
        if page.Title and page.Title.TitleText
        else "(untitled)"
    )
    print(f"  {title}  author={page.Author}  level={page.Level}")

Check for sub-pages

Sub-pages have Level > 0:

from aspose.note import Document, Page

doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
    if page.Level and page.Level > 0:
        title = page.Title.TitleText.Text if page.Title and page.Title.TitleText else ""
        print(f"Sub-page (level={page.Level}): {title!r}")

Access the full title block

The Title node contains three optional RichText children:

from aspose.note import Document, Page

doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
    if page.Title:
        if page.Title.TitleText:
            print("Text:", page.Title.TitleText.Text)
        if page.Title.TitleDate:
            print("Date:", page.Title.TitleDate.Text)
        if page.Title.TitleTime:
            print("Time:", page.Title.TitleTime.Text)

Extract all content from a single page

from aspose.note import Document, Page, RichText, Image, Table, AttachedFile

doc = Document("MyNotes.one")
page = doc.GetChildNodes(Page)[0]  # first page

print(f"RichText: {len(page.GetChildNodes(RichText))}")
print(f"Images:   {len(page.GetChildNodes(Image))}")
print(f"Tables:   {len(page.GetChildNodes(Table))}")
print(f"Files:    {len(page.GetChildNodes(AttachedFile))}")

Timestamps

from aspose.note import Document, Page

doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
    print(f"Created:  {page.CreationTime}")
    print(f"Modified: {page.LastModifiedTime}")

None-Safety

Title, Author, CreationTime, LastModifiedTime, and Level can all be None. Always guard:

title_text = (
    page.Title.TitleText.Text
    if page.Title and page.Title.TitleText
    else ""
)

See Also