Aspose.Note FOSS for Python
This reference covers the complete public API surface of aspose-note version 26.3.1. Only symbols exported from the aspose.note package are documented here. Anything under aspose.note._internal is an implementation detail and may change without notice.
Install: pip install aspose-note (core) or pip install "aspose-note[pdf]" (with PDF export)
Import: from aspose.note import Document, RichText, ...
Classes
Document and Traversal
| Class | Description |
|---|---|
Document | Root document object. Represents a OneNote document; iterate pages and export to PDF. |
DocumentVisitor | Abstract base for visitor-pattern traversal of the document tree. |
Node | Base class for all document nodes. |
CompositeNode | Base class for nodes that can contain child nodes. |
Document Structure
| Class | Description |
|---|---|
Page | Represents a OneNote page. |
Title | Page title block containing TitleText, TitleDate, TitleTime. |
Outline | Positional container for OutlineElement nodes. |
OutlineElement | Leaf container; holds RichText, Image, Table, AttachedFile. |
Content
| Class | Description |
|---|---|
RichText | Text block with formatting runs, tags, and hyperlinks. |
TextRun | Single formatted text segment within a RichText. |
TextStyle | Formatting properties for a TextRun. |
Image | Embedded image with raw bytes and metadata. |
AttachedFile | Embedded file attachment with raw bytes. |
Table | Table with rows, cells, and column widths. |
TableRow | A row within a Table. |
TableCell | A cell within a TableRow; contains content nodes. |
NoteTag | OneNote tag (star, checkbox, etc.) attached to a content node. |
NumberList | Numbered list metadata on an OutlineElement. |
Options
| Class | Description |
|---|---|
LoadOptions | Options for loading a .one file. |
SaveOptions | Base class for save options. |
PdfSaveOptions (see options and parameters) | Options class for document export: controls image compression, JPEG quality, and page settings for PDF output. |
Compatibility Stubs
| Class | Description |
|---|---|
License | Compatibility stub: SetLicense() is a no-op in this FOSS implementation. |
Metered | Compatibility stub: SetMeteredKey() is a no-op in this FOSS implementation. |
Class Details
Document
The root document class. Load a .one file from a file path, a pathlib.Path, or a binary stream.
from aspose.note import Document, LoadOptions
doc = Document(source=None, load_options=None)Constructor parameters:
| Parameter | Type | Description |
|---|---|---|
source | str | Path | BinaryIO | None | File path string, pathlib.Path, binary stream, or None for an empty document |
load_options | LoadOptions | None | Optional load-time configuration |
Properties:
| Property | Type | Description |
|---|---|---|
FileFormat | FileFormat | Best-effort indication of the OneNote file format version |
Methods:
| Method | Signature | Description |
|---|---|---|
GetPageHistory(page) | (Page) -> PageHistory | Returns [page] (stub; full history not yet implemented) |
DetectLayoutChanges() | () -> None | Compatibility stub; no operation |
Save(target, format_or_options) | (str | Path | BinaryIO, SaveFormat | SaveOptions | None) -> None | Save to file or stream. Only PDF format is implemented; raises ValueError for other formats |
Accept(visitor) | (DocumentVisitor) -> None | Invoke visitor traversal |
for page in doc | N/A | Iterate direct child Page nodes |
Document.FileFormatnote: The property provides a best-effort indication of the OneNote file format version. TheFileFormatenum has three values:OneNote2010,OneNoteOnline, andOneNote2007.
Document.Save()stream support:targetcan be a binary stream (io.BytesIO, file handle opened in binary write mode, etc.).
DocumentVisitor
Abstract base class for visitor-pattern traversal. Override the visit methods you need:
| Method | Called when |
|---|---|
VisitDocumentStart(doc) | Entering a Document node |
VisitDocumentEnd(doc) | Leaving a Document node |
VisitPageStart(page) | Entering a Page node |
VisitPageEnd(page) | Leaving a Page node |
VisitTitleStart(title) | Entering a Title node |
VisitTitleEnd(title) | Leaving a Title node |
VisitOutlineStart(outline) | Entering an Outline node |
VisitOutlineEnd(outline) | Leaving an Outline node |
VisitOutlineElementStart(oe) | Entering an OutlineElement node |
VisitOutlineElementEnd(oe) | Leaving an OutlineElement node |
VisitRichTextStart(rt) | Entering a RichText node |
VisitRichTextEnd(rt) | Leaving a RichText node |
VisitImageStart(img) | Entering an Image node |
VisitImageEnd(img) | Leaving an Image node |
Node
Base class for all document tree nodes.
| Property / Method | Type | Description |
|---|---|---|
ParentNode | Node | None | Parent in the document tree (None for the root Document) |
Document | Document | None | Walk up to the root Document; returns None if this node is not attached to a Document |
Accept(visitor) | (DocumentVisitor) -> None | Dispatch visitor for this node |
CompositeNode
Extends Node. Adds child management:
| Property / Method | Description |
|---|---|
FirstChild | First child node, or None |
LastChild | Last child node, or None |
AppendChildLast(node) | Add a child node at the end; sets node.ParentNode = self |
AppendChildFirst(node) | Add a child node at the start |
InsertChild(index, node) | Insert a child at the given position |
RemoveChild(node) | Remove a child node; sets node.ParentNode = None |
GetEnumerator() | Returns an iterator over direct children |
for child in node | Iterate direct children |
GetChildNodes(Type) | (Type) -> list[Type]: recursive, depth-first search of the entire subtree including self |
Page
Extends CompositeNode. Represents a OneNote page.
| Property | Type | Description |
|---|---|---|
Title | Title | None | Page title block |
Author | str | None | Author string |
CreationTime | datetime | None | Page creation timestamp |
LastModifiedTime | datetime | None | Last modification timestamp |
Level | int | None | Sub-page indent level (0 = top-level) |
Methods:
| Method | Description |
|---|---|
Clone(deep=False) | Return a shallow or deep clone of the page |
Title
Extends CompositeNode. Holds the title block of a Page.
| Property | Type | Description |
|---|---|---|
TitleText | RichText | None | Main title text |
TitleDate | RichText | None | Date portion of the title |
TitleTime | RichText | None | Time portion of the title |
Outline
Extends CompositeNode. A positional container for OutlineElement nodes.
| Property | Type | Description |
|---|---|---|
HorizontalOffset | float | None | Horizontal offset from the left edge of the page |
VerticalOffset | float | None | Vertical offset from the top of the page |
MaxWidth | float | None | Maximum width of the outline in points |
MaxHeight | float | None | Maximum height of the outline in points |
MinWidth | float | None | Minimum width of the outline in points |
ReservedWidth | float | None | Reserved width in points |
IndentPosition | float | None | Indent position for this outline |
OutlineElement
Extends CompositeNode. A leaf container that holds content nodes.
| Property | Type | Description |
|---|---|---|
NumberList | NumberList | None | Numbered list metadata, or None |
RichText
Extends Node. A block of styled text.
| Property | Type | Description |
|---|---|---|
Text | str | Full plain-text string (all runs concatenated) |
TextRuns | list[TextRun] | Ordered list of formatted segments |
Tags | list[NoteTag] | OneNote tags attached to this block |
Methods:
| Method | Signature | Description |
|---|---|---|
Append(text, style=None) | (str, TextStyle | None) -> RichText | Append text in-memory; if style is given, also appends a TextRun to TextRuns |
Replace(old_value, new_value) | (str, str) -> None | In-memory string substitution on Text; does not update TextRuns |
TextRun
A single formatted text segment within RichText.TextRuns.
| Property | Type | Description |
|---|---|---|
Text | str | The segment’s text content (default "") |
Style | TextStyle | Formatting properties |
TextStyle
Per-character formatting properties for a TextRun.
| Property | Type | Default | Description |
|---|---|---|---|
IsBold | bool | False | Bold |
IsItalic | bool | False | Italic |
IsUnderline | bool | False | Underline |
IsStrikethrough | bool | False | Strikethrough |
IsSuperscript | bool | False | Superscript |
IsSubscript | bool | False | Subscript |
FontName | str | None | None | Font family name |
FontSize | float | None | None | Font size in points |
FontColor | int | None | None | Font color as ARGB integer |
Highlight | int | None | None | Background highlight color as ARGB integer |
Language | int | None | None | Language identifier (LCID) |
IsHyperlink | bool | False | Whether this run is a hyperlink |
HyperlinkAddress | str | None | None | Hyperlink URL (when IsHyperlink is True) |
Image
Extends CompositeNode. An embedded image.
| Property | Type | Description |
|---|---|---|
FileName | str | None | Original filename of the image |
FilePath | str | None | Original file path of the image |
Format | str | None | Image format identifier string as stored in the OneNote file |
Bytes | bytes | Raw image byte data (default b"") |
OriginalWidth | float | None | Image width in points as stored in the file |
OriginalHeight | float | None | Image height in points as stored in the file |
Alignment | HorizontalAlignment | None | Horizontal alignment of the image |
Tags | list[NoteTag] | OneNote tags attached to this image |
Methods:
| Method | Description |
|---|---|
Replace(image) | Copy Bytes and FileName from another Image node into this one |
AttachedFile
Extends Node. An embedded file attachment.
| Property | Type | Description |
|---|---|---|
FileName | str | None | Original filename |
Bytes | bytes | Raw file data (default b"") |
Tags | list[NoteTag] | OneNote tags attached to this attachment |
Table
Extends CompositeNode. A table within an OutlineElement.
| Property | Type | Default | Description |
|---|---|---|---|
Columns | list[TableColumn] | [] | List of column metadata; each TableColumn has .Width (float) and .LockedWidth (bool) |
Tags | list[NoteTag] | [] | OneNote tags attached to this table |
TableRow
Extends CompositeNode. A row within a Table. Iterate GetChildNodes(TableCell) to access cells.
TableCell
Extends CompositeNode. A cell within a TableRow. Contains RichText, Image, and other content nodes.
NoteTag
A OneNote tag attached to a content node.
| Property | Type | Default | Description |
|---|---|---|---|
Icon | int | None | None | Numeric shape identifier for the tag icon |
Label | str | None | None | Display label string (e.g. "Yellow Star", "Important") |
FontColor | int | None | None | Tag text color as ARGB integer |
Highlight | int | None | None | Tag highlight color as ARGB integer |
CreationTime | datetime | None | None | When the tag was created |
CompletedTime | datetime | None | None | When the tag was completed (None = not completed) |
Status | TagStatus | derived | TagStatus.Completed if CompletedTime is set, else TagStatus.Open |
Factory methods:
| Method | Description |
|---|---|
NoteTag.CreateYellowStar(label=None) | Creates a NoteTag(Label="Yellow Star", Icon=13) |
NoteTag.CreateQuestionMark(label=None) | Creates a NoteTag(Label="Question Mark", Icon=15) |
NoteTag.CreateMusicalNote(label=None) | Creates a NoteTag(Label="Musical Note", Icon=121) |
NumberList
Numbered or bulleted list metadata on an OutlineElement.
| Property | Type | Default | Description |
|---|---|---|---|
Format | str | None | None | Number format string from MS-ONE |
NumberFormat | str | None | None | Alternate number format string |
Font | str | None | None | Font family name for the list prefix |
FontSize | float | None | None | Font size in points for the list prefix |
FontColor | int | None | None | Font color as ARGB integer for the list prefix |
IsBold | bool | False | Bold weight for the list prefix |
IsItalic | bool | False | Italic style for the list prefix |
Restart | int | None | None | Explicit restart number |
LoadOptions
| Property | Type | Default | Description |
|---|---|---|---|
DocumentPassword | str | None | None | Setting this causes an IncorrectPasswordException at load time; encrypted documents are not supported |
LoadHistory | bool | False | API compatibility field; not functionally used in v26.3.1 |
SaveOptions
Base class for save options. Required positional argument.
| Property | Type | Description |
|---|---|---|
SaveFormat | SaveFormat | Target save format |
PdfSaveOptions
Extends SaveOptions. PDF-specific export configuration. Construct with PdfSaveOptions() (all arguments are keyword-only with defaults).
| Property | Type | Default | Description |
|---|---|---|---|
PageIndex | int | 0 | Field exists; not forwarded to PDF exporter in v26.3.1: has no effect on output |
PageCount | int | None | None | Field exists; not forwarded to PDF exporter in v26.3.1: has no effect on output |
ImageCompression | Any | None | None | Image compression setting for the PDF output |
JpegQuality | int | None | None | JPEG quality (0–100) for compressed images in the PDF |
PageSettings | Any | None | None | Per-page size and orientation settings |
PageSplittingAlgorithm | Any | None | None | Algorithm used to split long content across PDF pages |
PageIndex/PageCountcaveat: These fields are declared onPdfSaveOptionsfor API compatibility, but theDocument.Save()implementation in v26.3.1 does not apply or forward them to the PDF exporter. All pages are always exported.
License and Metered
Compatibility stubs exported for API shape compatibility with Aspose.Note for .NET. All methods are no-ops in this FOSS implementation.
from aspose.note import License, Metered
lic = License()
lic.SetLicense("path/to/license.lic") # no-op
m = Metered()
m.SetMeteredKey("public_key", "private_key") # no-opNo license key is required to use any feature of Aspose.Note FOSS for Python.
Enumerations
Full enumeration reference: Enumerations
SaveFormat
| Value | Description |
|---|---|
SaveFormat.Pdf | PDF export via ReportLab; raises ValueError if format handler not registered. Requires pip install "aspose-note[pdf]" |
FileFormat
Enum values representing the OneNote file format version. Document.FileFormat provides a best-effort indication.
| Value | String value |
|---|---|
FileFormat.OneNote2010 | "onenote2010" |
FileFormat.OneNoteOnline | "onenoteonline" |
FileFormat.OneNote2007 | "onenote2007" |
HorizontalAlignment
| Value | String value |
|---|---|
HorizontalAlignment.Left | "left" |
HorizontalAlignment.Center | "center" |
HorizontalAlignment.Right | "right" |
NodeType
| Value | String value |
|---|---|
NodeType.Document | "document" |
NodeType.Page | "page" |
NodeType.Outline | "outline" |
NodeType.OutlineElement | "outline_element" |
NodeType.RichText | "rich_text" |
NodeType.Image | "image" |
NodeType.Table | "table" |
NodeType.AttachedFile | "attached_file" |
Exceptions
Full exception reference: Exceptions
| Exception | Description |
|---|---|
AsposeNoteError | Base class for all Aspose.Note FOSS exceptions |
FileCorruptedException | The .one file cannot be parsed (corrupted or malformed binary) |
IncorrectDocumentStructureException | The file structure is invalid or unsupported |
IncorrectPasswordException | Raised when LoadOptions.DocumentPassword is set; encrypted documents are not supported |
UnsupportedFileFormatException | The file format is not recognized; exposes a FileFormat field (string) |
UnsupportedSaveFormatException | The requested SaveFormat is not implemented in this version |