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
| Enumerations | Enumerations | Enumerations | Enumerations |
|---|---|---|---|
Title | `Title | None` | Enumerations |
Author | `str | None` | Enumerations |
CreationTime | `datetime | None` | Enumerations |
LastModifiedTime | `datetime | None` | Enumerations |
Level | `int | None` | Enumerations |
Успадковано від CompositeNode
| Властивість / Метод | Enumerations |
|---|---|
FirstChild | Перший прямий дочірній вузол |
LastChild | Останній прямий дочірній вузол |
GetChildNodes(Type) | Рекурсивний пошук, відфільтрований за типом |
for child in page | Ітерація безпосередніх дочірніх елементів (Outlines) |
Успадковано від Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Батьківський елемент Document |
Document | Корінь Document |
Enumerations
Enumerations
page.Clone(deep: bool = False) -> PageПовертає копію сторінки. deep=False створює поверхневий клон без дочірніх елементів.
Accept(visitor)
page.Accept(visitor: DocumentVisitor) -> NoneEnumerations 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 ""
)Див. також
- Enumerations: батьківський елемент Page
- Enumerations: вузол заголовка
- Enumerations: контейнер схеми
- RichText: текстовий вміст
- Посібник розробника з видобутку тексту
- How-to: Видобути текст по сторінці (KB)