Aspose.Note FOSS for Python

This reference covers the complete public API surface of aspose-note version 26.2. 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

ClassDescription
DocumentRoot document object. Load a .one file, iterate pages, and save to PDF.
DocumentVisitorAbstract base for visitor-pattern traversal of the document tree.
NodeBase class for all document nodes.
CompositeNodeBase class for nodes that can contain child nodes.

Document Structure

ClassDescription
PageRepresents a OneNote page.
TitlePage title block containing TitleText, TitleDate, TitleTime.
OutlinePositional container for OutlineElement nodes.
OutlineElementLeaf container; holds RichText, Image, Table, AttachedFile.

Content

ClassDescription
RichTextText block with formatting runs, tags, and hyperlinks.
TextRunSingle formatted text segment within a RichText.
TextStyleFormatting properties for a TextRun.
ImageEmbedded image with raw bytes and metadata.
AttachedFileEmbedded file attachment with raw bytes.
TableTable with rows, cells, and column widths.
TableRowA row within a Table.
TableCellA cell within a TableRow; contains content nodes.
NoteTagOneNote tag (star, checkbox, etc.) attached to a content node.
NumberListNumbered list metadata on an OutlineElement.

Options

ClassDescription
LoadOptionsOptions for loading a .one file.
SaveOptionsBase class for save options.
PdfSaveOptionsPDF-specific save options (tag icons).
OneSaveOptionsDeclared for API compatibility; not implemented.
HtmlSaveOptionsDeclared for API compatibility; not implemented.
ImageSaveOptionsDeclared for API compatibility; not implemented.

Compatibility Stubs

ClassDescription
LicenseCompatibility stub: SetLicense() is a no-op in this FOSS implementation.
MeteredCompatibility 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:

ParameterTypeDescription
sourcestr | Path | BinaryIO | NoneFile path string, pathlib.Path, binary stream, or None for an empty document
load_optionsLoadOptions | NoneOptional load-time configuration

Properties:

PropertyTypeDescription
DisplayNamestr | NoneSection display name from the file metadata
CreationTimedatetime | NoneField exists; not populated from the parser in v26.2 (always None)
FileFormatFileFormatAlways returns FileFormat.OneNote2010: hardcoded constant in v26.2, not a detected value

Methods:

MethodSignatureDescription
Count()() -> intNumber of direct child pages
GetPageHistory(page)(Page) -> list[Page]Returns [page] (stub; full history not yet implemented)
DetectLayoutChanges()() -> NoneCompatibility stub; no operation
Save(target, format_or_options)(str | Path | BinaryIO, SaveFormat | SaveOptions | None) -> NoneSave to file or stream. Only SaveFormat.Pdf is implemented
Accept(visitor)(DocumentVisitor) -> NoneInvoke visitor traversal
for page in docN/AIterate direct child Page nodes

Document.FileFormat note: The property always returns FileFormat.OneNote2010 regardless of the actual file. The FileFormat enum has three values (OneNote2010, OneNoteOnline, OneNote2007) but format detection is not yet implemented.

Document.Save() stream support: target can be a binary stream (io.BytesIO, file handle opened in binary write mode, etc.). This is confirmed by the test suite: doc.Save(io.BytesIO(), PdfSaveOptions(SaveFormat.Pdf)).


DocumentVisitor

Abstract base class for visitor-pattern traversal. Override the visit methods you need:

MethodCalled 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 / MethodTypeDescription
ParentNodeNode | NoneParent in the document tree (None for the root Document)
DocumentDocument | NoneWalk up to the root Document; returns None if this node is not attached to a Document
Accept(visitor)(DocumentVisitor) -> NoneDispatch visitor for this node

CompositeNode

Extends Node. Adds child management:

Property / MethodDescription
FirstChildFirst child node, or None
LastChildLast 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 nodeIterate direct children
GetChildNodes(Type)(Type) -> list[Type]: recursive, depth-first search of the entire subtree including self

Page

Extends CompositeNode. Represents a OneNote page.

PropertyTypeDescription
TitleTitle | NonePage title block
Authorstr | NoneAuthor string
CreationTimedatetime | NonePage creation timestamp
LastModifiedTimedatetime | NoneLast modification timestamp
Levelint | NoneSub-page indent level (0 = top-level)

Methods:

MethodDescription
Clone(deep=False)Return a shallow or deep clone of the page

Title

Extends CompositeNode. Holds the title block of a Page.

PropertyTypeDescription
TitleTextRichText | NoneMain title text
TitleDateRichText | NoneDate portion of the title
TitleTimeRichText | NoneTime portion of the title

Outline

Extends CompositeNode. A positional container for OutlineElement nodes.

PropertyTypeDescription
Xfloat | NoneHorizontal position on the page
Yfloat | NoneVertical position on the page
Widthfloat | NoneWidth in points

OutlineElement

Extends CompositeNode. A leaf container that holds content nodes.

PropertyTypeDescription
IndentLevelintNesting depth (0 = outermost)
NumberListNumberList | NoneNumbered list metadata, or None
Tagslist[NoteTag]OneNote tags attached to this element

RichText

Extends CompositeNode. A block of styled text.

PropertyTypeDescription
TextstrFull plain-text string (all runs concatenated)
Runslist[TextRun]Ordered list of formatted segments
FontSizefloat | NoneParagraph-level font size in points
Tagslist[NoteTag]OneNote tags attached to this block

Methods:

MethodSignatureDescription
Append(text, style=None)(str, TextStyle | None) -> RichTextAppend text in-memory; if style is given, also appends a TextRun to Runs
Replace(old_value, new_value)(str, str) -> NoneIn-memory string substitution on Text; does not update Runs

TextRun

Extends Node. A single formatted text segment.

PropertyTypeDescription
TextstrThe segment’s text content (default "")
StyleTextStyleFormatting properties
Startint | NoneCharacter offset of the segment start within RichText.Text
Endint | NoneCharacter offset of the segment end

TextStyle

Extends Node. Per-character formatting properties for a TextRun.

PropertyTypeDefaultDescription
BoldboolFalseBold
ItalicboolFalseItalic
UnderlineboolFalseUnderline
StrikethroughboolFalseStrikethrough
SuperscriptboolFalseSuperscript
SubscriptboolFalseSubscript
FontNamestr | NoneNoneFont family name
FontSizefloat | NoneNoneFont size in points
FontColorint | NoneNoneFont color as ARGB integer
HighlightColorint | NoneNoneBackground highlight color as ARGB integer
LanguageIdint | NoneNoneLanguage identifier (LCID)
IsHyperlinkboolFalseWhether this run is a hyperlink
HyperlinkAddressstr | NoneNoneHyperlink URL (when IsHyperlink is True)

Image

Extends CompositeNode. An embedded image.

PropertyTypeDescription
FileNamestr | NoneOriginal filename of the image
BytesbytesRaw image data (default b"")
Widthfloat | NoneImage width in points
Heightfloat | NoneImage height in points
AlternativeTextTitlestr | NoneAlt text title field (always None for files parsed in v26.2: the parser does not populate it)
AlternativeTextDescriptionstr | NoneAlt text description (populated from the parser’s alt_text field)
HyperlinkUrlstr | NoneURL if the image is a hyperlink
Tagslist[NoteTag]OneNote tags attached to this image

Methods:

MethodDescription
Replace(image)Copy Bytes and FileName from another Image node into this one

AttachedFile

Extends CompositeNode. An embedded file attachment.

PropertyTypeDescription
FileNamestr | NoneOriginal filename
BytesbytesRaw file data (default b"")
Tagslist[NoteTag]OneNote tags attached to this attachment

Table

Extends CompositeNode. A table within an OutlineElement.

PropertyTypeDefaultDescription
ColumnWidthslist[float][]Width of each column in points
BordersVisibleboolTrueWhether table borders are visible
Tagslist[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

Extends Node. A OneNote tag attached to a content node.

FieldTypeDefaultDescription
shapeint | NoneNoneNumeric shape identifier for the tag icon
labelstr | NoneNoneDisplay label string (e.g. "Yellow Star", "Important")
text_colorint | NoneNoneText color as raw integer
highlight_colorint | NoneNoneHighlight color as raw integer
createdint | NoneNoneRaw MS timestamp integer when the tag was created
completedint | NoneNoneRaw MS timestamp integer when the tag was completed (None = not completed)

Timestamp note: created and completed are raw integer timestamps as parsed from the MS-ONE binary format, not datetime objects.

Factory methods:

MethodDescription
NoteTag.CreateYellowStar()Creates a NoteTag(shape=None, label="Yellow Star")

NumberList

Extends Node. Numbered or bulleted list metadata on an OutlineElement.

PropertyTypeDefaultDescription
Formatstr | NoneNoneNumber format string from MS-ONE
Restartint | NoneNoneExplicit restart number
IsNumberedboolFalseTrue for ordered (numbered) lists

LoadOptions

PropertyTypeDefaultDescription
DocumentPasswordstr | NoneNoneSetting this causes an IncorrectPasswordException at load time; encrypted documents are not supported
LoadHistoryboolFalseAPI compatibility field; not functionally used in v26.2

SaveOptions

Base class for all save options. Required positional argument.

PropertyTypeDescription
SaveFormatSaveFormatTarget save format

PdfSaveOptions

Extends SaveOptions. PDF-specific export configuration. Construct with PdfSaveOptions(SaveFormat.Pdf).

PropertyTypeDefaultDescription
PageIndexint0Field exists; not forwarded to PDF exporter in v26.2: has no effect on output
PageCountint | NoneNoneField exists; not forwarded to PDF exporter in v26.2: has no effect on output
TagIconDirstr | NoneNoneDirectory containing custom tag icon PNG files: forwarded and applied
TagIconSizefloat | NoneNoneTag icon size in points: forwarded and applied
TagIconGapfloat | NoneNoneHorizontal gap around tag icons in points: forwarded and applied

PageIndex / PageCount caveat: These fields are declared on PdfSaveOptions for API compatibility, but the Document.Save() implementation in v26.2 does not read or forward them to the PDF exporter. All pages are always exported.

OneSaveOptions, HtmlSaveOptions, ImageSaveOptions

Declared for API compatibility with Aspose.Note for .NET. Attempting to use them with Document.Save() raises UnsupportedSaveFormatException.

ClassExtra fields
OneSaveOptionsDocumentPassword: str | None
HtmlSaveOptionsPageIndex: int, PageCount: int | None
ImageSaveOptionsPageIndex: int, PageCount: int | None, Quality: int | None, Resolution: int | None

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-op

No license key is required to use any feature of Aspose.Note FOSS for Python.


Enumerations

Full enumeration reference: Enumerations

SaveFormat

ValueDescription
SaveFormat.PdfPDF export: implemented; requires pip install "aspose-note[pdf]"
SaveFormat.OneOneNote format: declared only; raises UnsupportedSaveFormatException
SaveFormat.HtmlHTML: declared only; raises UnsupportedSaveFormatException
SaveFormat.JpegJPEG image: declared only; raises UnsupportedSaveFormatException
SaveFormat.PngPNG image: declared only; raises UnsupportedSaveFormatException
SaveFormat.GifGIF image: declared only; raises UnsupportedSaveFormatException
SaveFormat.BmpBMP image: declared only; raises UnsupportedSaveFormatException
SaveFormat.TiffTIFF image: declared only; raises UnsupportedSaveFormatException

FileFormat

Enum values used for API compatibility. Document.FileFormat always returns FileFormat.OneNote2010 in v26.2.

ValueString value
FileFormat.OneNote2010"onenote2010"
FileFormat.OneNoteOnline"onenoteonline"
FileFormat.OneNote2007"onenote2007"

HorizontalAlignment

ValueString value
HorizontalAlignment.Left"left"
HorizontalAlignment.Center"center"
HorizontalAlignment.Right"right"

NodeType

ValueString 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

ExceptionDescription
AsposeNoteErrorBase class for all Aspose.Note FOSS exceptions
FileCorruptedExceptionThe .one file cannot be parsed (corrupted or malformed binary)
IncorrectDocumentStructureExceptionThe file structure is invalid or unsupported
IncorrectPasswordExceptionRaised when LoadOptions.DocumentPassword is set; encrypted documents are not supported
UnsupportedFileFormatExceptionThe file format is not recognized; exposes a FileFormat field (string)
UnsupportedSaveFormatExceptionThe requested SaveFormat is not implemented in this version

See Also