1. Products
  2.   Aspose.Note
  3.   Aspose.Note FOSS for Python

Aspose.Note FOSS for Python

Read, traverse, and export Microsoft OneNote (.one) files from Python — free and open-source, no Microsoft Office required.

Open-Source Python Library for OneNote Files

Aspose.Note FOSS for Python is a 100% free, MIT-licensed library that lets you read Microsoft OneNote (.one) files entirely from Python, with no Microsoft Office, no COM automation, and no proprietary runtime required. It exposes a clean public API (aspose.note.*) modeled on the familiar Aspose.Note for .NET interface, backed by a built-in MS-ONE/OneStore binary parser written in pure Python.

Install from PyPI with pip install aspose-note (or pip install "aspose-note[pdf]" to enable PDF export). Requires Python 3.10 or later.

The library is suitable for document automation scripts, content indexing pipelines, archival tools, and any server-side workflow that needs to consume OneNote content without a Microsoft Office dependency.

Read and Traverse OneNote Documents

  • Load .one files: Open any OneNote section from a file path or binary stream via Document.
  • Full DOM traversal: Navigate Document → Page → Outline → OutlineElement → RichText / Image / Table / AttachedFile.
  • Rich text extraction: Read raw text via RichText.Text or inspect TextRun segments for bold, italic, font, color, and hyperlink metadata.
  • Table parsing: Traverse Table → TableRow → TableCell hierarchies with column widths and border visibility.
  • Tag inspection: Read NoteTag metadata (shape, label, color, completion state) on text, image, and table nodes.

Where Aspose.Note FOSS Can Be Used

  • Content indexing: Extract and index all text from OneNote archives for search pipelines.
  • Document migration: Convert OneNote sections to PDF, plain text, or structured data.
  • Archival tools: Save embedded images and attachments to disk from .one files.
  • CI/CD workflows: Validate or process OneNote content inside Docker containers.
  • Knowledge-base pipelines: Extract structured content from team OneNote notebooks.

Export, Images, and Attachments

  • PDF export: Save any loaded Document to PDF using Document.Save(path, SaveFormat.Pdf).
  • PDF options: Customize page range, tag icon directory, icon size, and gap via PdfSaveOptions.
  • Image export: Iterate Image nodes to retrieve raw bytes, filename, dimensions, and alt text.
  • Attachment saving: Iterate AttachedFile nodes to save embedded file attachments to disk.
  • Stream-based loading: Open .one files from a binary stream (e.g., io.BytesIO) without writing to disk.

Developer Experience

Aspose.Note FOSS installs with a single pip install aspose-note command. The base package has no optional dependencies; PDF export requires ReportLab, installed via pip install "aspose-note[pdf]".

The API is modeled on the familiar Aspose.Note for .NET interface: Document, Page, Outline, RichText, Image, Table, AttachedFile. The library is MIT-licensed, open-source, and accepts bug reports and contributions on GitHub.

Load a OneNote File and Extract All Text

Install with pip, then pass a file path to Document() to parse the OneNote binary format. GetChildNodes(RichText) performs a deep recursive search and returns every text node in the document, which is useful for full-text indexing or migration pipelines.

pip install aspose-note
from aspose.note import Document, RichText

doc = Document("notebook.one")
print(f"Pages: {doc.Count()}")

# Extract all text across the entire document
texts = [rt.Text for rt in doc.GetChildNodes(RichText) if rt.Text]
for text in texts:
    print(text)

Export to PDF and Save Attached Images

PDF export requires the optional ReportLab dependency. Install it with pip install "aspose-note[pdf]". The same Document object can also be iterated for Image nodes to extract and save all embedded images to disk in one pass.

from aspose.note import Document, SaveFormat, Image
import pathlib

doc = Document("notebook.one")

# Export the document to PDF (requires aspose-note[pdf])
doc.Save("output.pdf", SaveFormat.Pdf)

# Save all embedded images to disk
out_dir = pathlib.Path("images")
out_dir.mkdir(exist_ok=True)
for i, img in enumerate(doc.GetChildNodes(Image)):
    name = img.FileName or f"image_{i}.bin"
    (out_dir / name).write_bytes(img.Bytes)

Frequently Asked Questions

What is Aspose.Note FOSS for Python?

It is a free, MIT-licensed Python library for reading Microsoft OneNote (.one) files without requiring Microsoft Office, COM automation, or any proprietary runtime.

Which OneNote format variants are supported?

OneNote 2010, OneNote Online, and OneNote 2007 format variants. Any valid .one section file can be loaded.

How do I install it?

Run pip install aspose-note for the base library, or pip install "aspose-note[pdf]" to include the optional ReportLab dependency for PDF export.

Can I export OneNote files to PDF?

Yes. Call Document.Save(path, SaveFormat.Pdf). PDF export requires the optional ReportLab dependency installed via the [pdf] extra.

Can I load .one files from a stream?

Yes. The Document class accepts a binary stream (e.g., io.BytesIO or an HTTP response body) so you can process files without writing to disk.

What Python version is required?

Python 3.10 or later is required.

Can I write or modify a .one file?

No. The current edition is read-only. It can open and parse any valid .one section file, but writing back to the OneNote binary format is not supported.

Are encrypted OneNote documents supported?

No. Loading a password-protected .one file raises an IncorrectPasswordException. Encrypted documents are not supported in the current edition.

Where can I find the source code?

The library is MIT-licensed and hosted on GitHub. Bug reports and pull requests are welcome.

  

Support and Learning Resources