Page — Aspose.Note FOSS for Python API Reference

Клас: Page

Enumerations: aspose.note Enumerations: from aspose.note import Page Enumerations: CompositeNode

Page представляє окрему сторінку OneNote у Document.Сторінки є безпосередніми дочірніми елементами Document.Кожна сторінка може містити Outline вузли (які, у свою чергу, містять OutlineElement і вузли вмісту).


Enumerations

EnumerationsEnumerationsEnumerationsEnumerations
Title`TitleNone`Enumerations
Author`strNone`Enumerations
CreationTime`datetimeNone`Enumerations
LastModifiedTime`datetimeNone`Enumerations
Level`intNone`Enumerations

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

Властивість / МетодEnumerations
FirstChildПерший прямий дочірній вузол
LastChildОстанній прямий дочірній вузол
GetChildNodes(Type)Рекурсивний пошук, відфільтрований за типом
for child in pageІтерація безпосередніх дочірніх елементів (Outlines)

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

EnumerationsEnumerations
ParentNodeБатьківський елемент Document
DocumentКорінь Document

Enumerations

Enumerations

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

Повертає копію сторінки. deep=False створює поверхневий клон без дочірніх елементів.


Accept(visitor)

page.Accept(visitor: DocumentVisitor) -> None

Enumerations VisitPageStart(page) на відвідувача, потім рекурсивно відвідує дочірні вузли, потім VisitPageEnd(page).


Приклади використання

Перебрати всі сторінки

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

Перевірити наявність підсторінок

Підсторінки мають 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}")

Отримати повний блок заголовка

Enumerations Title node містить три необов’язкові RichText дочірні елементи:

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)

Витягнути весь вміст з однієї сторінки

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

Enumerations

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

Title, Author, CreationTime, LastModifiedTime, і Level можуть усі бути None. Завжди захищайте:

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

Див. також

 Українська