Title — Aspose.Note FOSS for Python API Reference
Class: Title
Package: aspose.note
Import: from aspose.note import Title
Inherits: CompositeNode
Title holds the title block of a Page. It is always accessible as page.Title and is also the first child node in the page’s child list (inserted via AppendChildFirst during document loading). It contains up to three RichText children: TitleText, TitleDate, and TitleTime.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
TitleText | RichText | None | Read | Main title text node |
TitleDate | RichText | None | Read | Date portion of the title, or None if not present |
TitleTime | RichText | None | Read | Time portion of the title, or None if not present |
Inherited from CompositeNode
| Property / Method | Description |
|---|---|
FirstChild | First direct child (typically the TitleText RichText node) |
LastChild | Last direct child |
AppendChildLast(node) | Append a child node |
GetChildNodes(Type) | Recursive depth-first search |
for child in title | Iterate direct children |
Inherited from Node
| Property | Description |
|---|---|
ParentNode | The containing Page |
Document | The root Document |
Methods
Accept(visitor)
title.Accept(visitor: DocumentVisitor) -> NoneDispatches VisitTitleStart(title), recursively visits child RichText nodes, then VisitTitleEnd(title).
Usage Examples
Read a page title
from aspose.note import Document, Page
doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
title = page.Title
if title and title.TitleText:
print("Title:", title.TitleText.Text)
if title and title.TitleDate:
print("Date:", title.TitleDate.Text)
if title and title.TitleTime:
print("Time:", title.TitleTime.Text)Safe title extraction helper
from aspose.note import Document, Page
def get_title(page: Page) -> str:
if page.Title and page.Title.TitleText:
return page.Title.TitleText.Text
return "(untitled)"
doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
print(get_title(page))Access the title node via GetChildNodes
Title is a real child node in the Page subtree, so it can be found with GetChildNodes:
from aspose.note import Document, Page, Title
doc = Document("MyNotes.one")
for page in doc.GetChildNodes(Page):
titles = page.GetChildNodes(Title)
if titles:
t = titles[0]
print("TitleText:", t.TitleText.Text if t.TitleText else None)Use visitor to collect title text
from aspose.note import Document, DocumentVisitor, Title
class TitleCollector(DocumentVisitor):
def __init__(self):
self.titles = []
def VisitTitleStart(self, title: Title) -> None:
if title.TitleText:
self.titles.append(title.TitleText.Text)
doc = Document("MyNotes.one")
collector = TitleCollector()
doc.Accept(collector)
print(collector.titles)None-Safety
page.Title itself may be None for pages with no title metadata. TitleDate and TitleTime are None when not present. Always guard:
text = page.Title.TitleText.Text if page.Title and page.Title.TitleText else ""See Also
- Page: parent node; exposes
page.Title - RichText: the type of TitleText, TitleDate, TitleTime
- DocumentVisitor:
VisitTitleStart/VisitTitleEnd