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

ClassDescription
DocumentRoot document object. Represents a OneNote document; iterate pages and export 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.
PdfSaveOptions (see options and parameters)Options class for document export: controls image compression, JPEG quality, and page settings for PDF output.

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
FileFormatFileFormatBest-effort indication of the OneNote file format version

Methods:

MethodSignatureDescription
GetPageHistory(page)(Page) -> PageHistoryReturns [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 PDF format is implemented; raises ValueError for other formats
Accept(visitor)(DocumentVisitor) -> NoneInvoke visitor traversal
for page in docN/AIterate direct child Page nodes

Document.FileFormat note: The property provides a best-effort indication of the OneNote file format version. The FileFormat enum has three values: OneNote2010, OneNoteOnline, and OneNote2007.

Document.Save() stream support: target can 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:

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
HorizontalOffsetfloat | NoneHorizontal offset from the left edge of the page
VerticalOffsetfloat | NoneVertical offset from the top of the page
MaxWidthfloat | NoneMaximum width of the outline in points
MaxHeightfloat | NoneMaximum height of the outline in points
MinWidthfloat | NoneMinimum width of the outline in points
ReservedWidthfloat | NoneReserved width in points
IndentPositionfloat | NoneIndent position for this outline

OutlineElement

Extends CompositeNode. A leaf container that holds content nodes.

PropertyTypeDescription
NumberListNumberList | NoneNumbered list metadata, or None

RichText

Extends Node. A block of styled text.

PropertyTypeDescription
TextstrFull plain-text string (all runs concatenated)
TextRunslist[TextRun]Ordered list of formatted segments
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 TextRuns
Replace(old_value, new_value)(str, str) -> NoneIn-memory string substitution on Text; does not update TextRuns

TextRun

A single formatted text segment within RichText.TextRuns.

PropertyTypeDescription
TextstrThe segment’s text content (default "")
StyleTextStyleFormatting properties

TextStyle

Per-character formatting properties for a TextRun.

PropertyTypeDefaultDescription
IsBoldboolFalseBold
IsItalicboolFalseItalic
IsUnderlineboolFalseUnderline
IsStrikethroughboolFalseStrikethrough
IsSuperscriptboolFalseSuperscript
IsSubscriptboolFalseSubscript
FontNamestr | NoneNoneFont family name
FontSizefloat | NoneNoneFont size in points
FontColorint | NoneNoneFont color as ARGB integer
Highlightint | NoneNoneBackground highlight color as ARGB integer
Languageint | 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
FilePathstr | NoneOriginal file path of the image
Formatstr | NoneImage format identifier string as stored in the OneNote file
BytesbytesRaw image byte data (default b"")
OriginalWidthfloat | NoneImage width in points as stored in the file
OriginalHeightfloat | NoneImage height in points as stored in the file
AlignmentHorizontalAlignment | NoneHorizontal alignment of the image
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 Node. 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
Columnslist[TableColumn][]List of column metadata; each TableColumn has .Width (float) and .LockedWidth (bool)
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

A OneNote tag attached to a content node.

PropertyTypeDefaultDescription
Iconint | NoneNoneNumeric shape identifier for the tag icon
Labelstr | NoneNoneDisplay label string (e.g. "Yellow Star", "Important")
FontColorint | NoneNoneTag text color as ARGB integer
Highlightint | NoneNoneTag highlight color as ARGB integer
CreationTimedatetime | NoneNoneWhen the tag was created
CompletedTimedatetime | NoneNoneWhen the tag was completed (None = not completed)
StatusTagStatusderivedTagStatus.Completed if CompletedTime is set, else TagStatus.Open

Factory methods:

MethodDescription
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.

PropertyTypeDefaultDescription
Formatstr | NoneNoneNumber format string from MS-ONE
NumberFormatstr | NoneNoneAlternate number format string
Fontstr | NoneNoneFont family name for the list prefix
FontSizefloat | NoneNoneFont size in points for the list prefix
FontColorint | NoneNoneFont color as ARGB integer for the list prefix
IsBoldboolFalseBold weight for the list prefix
IsItalicboolFalseItalic style for the list prefix
Restartint | NoneNoneExplicit restart number

LoadOptions

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

SaveOptions

Base class for save options. Required positional argument.

PropertyTypeDescription
SaveFormatSaveFormatTarget save format

PdfSaveOptions

Extends SaveOptions. PDF-specific export configuration. Construct with PdfSaveOptions() (all arguments are keyword-only with defaults).

PropertyTypeDefaultDescription
PageIndexint0Field exists; not forwarded to PDF exporter in v26.3.1: has no effect on output
PageCountint | NoneNoneField exists; not forwarded to PDF exporter in v26.3.1: has no effect on output
ImageCompressionAny | NoneNoneImage compression setting for the PDF output
JpegQualityint | NoneNoneJPEG quality (0–100) for compressed images in the PDF
PageSettingsAny | NoneNonePer-page size and orientation settings
PageSplittingAlgorithmAny | NoneNoneAlgorithm used to split long content across PDF pages

PageIndex / PageCount caveat: These fields are declared on PdfSaveOptions for API compatibility, but the Document.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-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 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.

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