Introduction
aspose-note converts Microsoft OneNote .one files to PDF entirely in Python — no
Microsoft Office, no external PDF renderer. This guide covers the export path in
depth: the basic Document.Save() call, tuning output with PdfSaveOptions, writing
to an in-memory buffer, converting a whole folder of notebooks in one pass, and what
“export-only” actually means for your workflow.
pip install aspose-noteBasic Export
The shortest path from a notebook to a PDF is a two-line call: load the .one file
into a Document, then save it with the SaveFormat.Pdf constant — no options object
is needed for the default output:
from aspose.note import Document, SaveFormat
doc = Document("notebook.one")
doc.Save("notebook.pdf", SaveFormat.Pdf)
Tuning Output with PdfSaveOptions
For anything beyond the default output, pass a PdfSaveOptions instance instead of
SaveFormat.Pdf — Document.Save() accepts either. PdfSaveOptions defaults to
PageIndex=0 and PageCount=None (every page), and exposes JpegQuality for embedded
image compression:
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("notebook.one")
# Compress embedded images more aggressively
opts = PdfSaveOptions(JpegQuality=90)
doc.Save("notebook-compressed.pdf", opts)
PageIndex and PageCount export a specific page range instead of the whole notebook —
useful for previewing a large notebook or splitting it into smaller PDFs:
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("notebook.one")
# Export 3 pages starting at index 2
opts = PdfSaveOptions(PageIndex=2, PageCount=3)
doc.Save("notebook-excerpt.pdf", opts)
Saving to an In-Memory Buffer
Document.Save() accepts any binary stream in place of a file path, so you can generate
a PDF without touching disk — useful when serving the result from a web request or
passing it directly to another library:
import io
from aspose.note import Document
from aspose.note.saving import PdfSaveOptions
doc = Document("notebook.one")
buf = io.BytesIO()
doc.Save(buf, PdfSaveOptions())
pdf_bytes = buf.getvalue()
print(f"PDF size: {len(pdf_bytes)} bytes")
Batch Converting a Folder of Notebooks
The same Document/Save() pair scales to a directory of files with a plain loop —
no batching API is required:
import pathlib
from aspose.note import Document, SaveFormat
source_dir = pathlib.Path("notebooks")
output_dir = pathlib.Path("pdf_output")
output_dir.mkdir(exist_ok=True)
for one_file in source_dir.glob("*.one"):
doc = Document(str(one_file))
doc.Save(str(output_dir / f"{one_file.stem}.pdf"), SaveFormat.Pdf)
print(f"Converted {one_file.name}")
Export-Only: What It Means in Practice
Aspose.Note FOSS for Python reads .one files and writes PDF — it does not write back
to .one. That also applies to notebooks built in-process: see
Aspose.Note FOSS for Python — Key Features
for constructing a Document tree from scratch with AppendChildLast() — its output path
is PDF as well, since .one write support is not part of this library.