Introduction

Aspose.Note FOSS for Python (aspose-note on PyPI) is a free, MIT-licensed library for reading Microsoft OneNote .one files and exporting to PDF in pure Python. Version 26.3.2 ships with a complete document object model covering pages, outlines, rich-text nodes, images, and attached files — no Microsoft Office installation or Windows dependency required.


Key Features

Document Loading and Format Detection

Document is the root of the object model. Pass a file path to load any supported OneNote format. The FileFormat property reports which format was detected.

from aspose.note import Document, FileFormat

doc = Document("notebook.one")
print(f"Format : {doc.FileFormat}")
print(f"Pages  : {len(list(doc))}")

Traversing Pages and Titles

Pages are Page nodes directly under the Document. Each Page exposes metadata such as Author, CreationTime, and Title. The Title node in turn provides TitleText, TitleDate, and TitleTime as RichText children.

from aspose.note import Document, Page

doc = Document("notebook.one")
for page in doc.GetChildNodes(Page):
    print(f"Author  : {page.Author}")
    print(f"Created : {page.CreationTime}")
    if page.Title and page.Title.TitleText:
        print(f"Title   : {page.Title.TitleText}")

Reading Rich Text Content

RichText nodes are the leaf nodes that carry the actual text content. Iterate a RichText object with a standard for loop — each item is a string segment. Use Append() to add new text with a style.

from aspose.note import Document, Page, Outline, RichText

doc = Document("notebook.one")
for page in doc.GetChildNodes(Page):
    for rt in page.GetChildNodes(RichText):
        text = "".join(rt)
        if text.strip():
            print(text[:120])

Outline Layout Properties

Outline nodes expose layout coordinates: HorizontalOffset, VerticalOffset, MaxWidth, MaxHeight, and MinWidth. These are useful for layout-aware extraction or re-composition of pages.

from aspose.note import Document, Outline

doc = Document("notebook.one")
for outline in doc.GetChildNodes(Outline):
    print(f"HOffset={outline.HorizontalOffset}  VOffset={outline.VerticalOffset}  MaxW={outline.MaxWidth}")

Document Tree Construction

Build a Document from scratch using CompositeNode.AppendChildLast(). Each node type can be added to its valid parent: PageDocument, OutlinePage, RichText nodes → Outline.

from aspose.note import Document, Page, Outline, RichText, ParagraphStyle, Title, SaveFormat

doc = Document()
page = Page()

title_text = RichText()
title_text.Append("My New Page", ParagraphStyle())
title = Title()
title.TitleText = title_text
page.Title = title

outline = Outline()
page.AppendChildLast(outline)
doc.AppendChildLast(page)
doc.Save("new_notebook.pdf", SaveFormat.Pdf)

Exporting to PDF

Document.Save() accepts SaveFormat.Pdf to write a PDF to a file path or a BytesIO buffer. The export runs entirely in-process without any external renderer.

import io
from aspose.note import Document, SaveFormat

doc = Document("notebook.one")

# File output
doc.Save("export.pdf", SaveFormat.Pdf)

# In-memory buffer
buf = io.BytesIO()
doc.Save(buf, SaveFormat.Pdf)
print(f"PDF bytes: {len(buf.getvalue())}")

Quick Start

pip install aspose-note>=26.3.2
from aspose.note import Document, Page, RichText, SaveFormat

doc = Document("notebook.one")

# Print all text
for page in doc.GetChildNodes(Page):
    for rt in page.GetChildNodes(RichText):
        print("".join(rt))

# Export to PDF
doc.Save("output.pdf", SaveFormat.Pdf)

Supported Formats

FormatExtensionReadWrite
OneNote 2010.one
OneNote 2007.one
OneNote Online.one
PDF.pdf

Open Source & Licensing

Aspose.Note FOSS for Python is released under the MIT License. Install from PyPI as aspose-note. Commercial use, redistribution, and modification are all permitted.


Getting Started