Page — Aspose.Note FOSS for Python API Reference
Lớp: Page
Enumerations: aspose.note Enumerations: from aspose.note import Page Enumerations: CompositeNode
Page đại diện cho một trang OneNote duy nhất trong một Document.Các trang là các nút con trực tiếp của Document.Mỗi trang có thể chứa Outline các nút (mà sau đó chứa OutlineElement và các nút nội dung).
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 |
Kế thừa từ CompositeNode
| Thuộc tính / Phương thức | Enumerations |
|---|---|
FirstChild | Nút con trực tiếp đầu tiên |
LastChild | Nút con trực tiếp cuối cùng |
GetChildNodes(Type) | Tìm kiếm đệ quy có bộ lọc loại |
for child in page | Lặp lại các phần tử con trực tiếp (Outlines) |
Kế thừa từ Node
| Enumerations | Enumerations |
|---|---|
ParentNode | Phần cha Document |
Document | Gốc Document |
Enumerations
Enumerations
page.Clone(deep: bool = False) -> PageTrả về một bản sao của trang. deep=False tạo một bản sao nông không có nút con.
Accept(visitor)
page.Accept(visitor: DocumentVisitor) -> NoneEnumerations VisitPageStart(page) trên visitor, sau đó đệ quy thăm các nút con, rồi VisitPageEnd(page).
Ví dụ sử dụng
Lặp qua tất cả các trang
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}")Kiểm tra các trang con
Các trang phụ có 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}")Truy cập khối tiêu đề đầy đủ
Enumerations Title nút chứa ba tùy chọn RichText các nút con:
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)Trích xuất toàn bộ nội dung từ một trang duy nhất
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-Safety
Title, Author, CreationTime, LastModifiedTime, và Level có thể đều là None. Luôn bảo vệ:
title_text = (
page.Title.TitleText.Text
if page.Title and page.Title.TitleText
else ""
)Xem Thêm
- Enumerations: cha của Page
- Enumerations: nút tiêu đề
- Enumerations: bộ chứa phác thảo
- RichText: nội dung văn bản
- Hướng dẫn nhà phát triển Trích xuất Văn bản
- Cách thực hiện: Trích xuất Văn bản theo Trang (KB)