Working with OneNote Notebook

Creating and Saving A Notebook

The Notebook class exposed by the API lets you create a notebook from scratch and save it as OneNote Notebook (.onetoc2). OneNote notebook can be created using the default constructor of Notebook class. This article shows creating and saving a Notebook document.

Saving Notebook to Stream

Support of Password Protected Documents Writing as Part of .onetoc2 Notebook

Reading Notebook File

The Notebook class exposed by the API lets you read a OneNote Notebook (.onetoc2) file from disc. The NotebookLoadOptions class provides further options to load the file with user-specified options.

Loading Notebook File

Loading Notebook File from Stream

Loading Notebook File with LoadOptions

By default, notebook’s child documents are loaded “lazily”, i.e. their loading is postponed until direct access to a specific child. An alternative approach is to load all children at once. The last can be achieved by passing to the Notebook constructor NotebookLoadOptions with the InstantLoading flag set to true. The following code snippets demonstrate both approaches.

Loading Notebook with Lazy Loading Option

Loading Notebook Instantly

Loading Password Protected Documents as a part of .onetoc2 Notebook

A password-protected notebook can be loaded with the help of LoadOptions class of the API specifying the password.

Adding a Child Node to OneNote Notebook

Aspose.Note API lets you add/append a child node to a OneNote Notebook. The appendChildLast method exposed by the Notebook class allows you to achieve this.

Remove a Child Node From OneNote Notebook

Aspose.Note API provides the capability to remove a child node from OneNote notebook. The removeChild method exposed by the API’s Notebook class lets you remove a child node that is meant to be removed from the Notebook.

Converting Notebook Document to Image

Aspose.Note API provides the capability to convert Notebook documents (.onetoc2) to image. The API can export the document to image directly or we can also specify additional save options using the NotebookImageSaveOptions class. This article shows all the approaches to export Notebook to the image.

Exporting Notebook to Image

Exporting Notebook to Image with Options

Export to Image as a Flattened Notebook

Converting Notebook Document to PDF

Aspose.Note API provides the capability to convert Notebook documents (.onetoc2) to PDF format. The API can export the document to PDF directly or we can also specify additional save options using the NotebookPdfSaveOptions class. This article shows all the approaches to export Notebook to PDF.

Please note that you cannot set values against the Application and Producer fields, because of Aspose Ltd. and Aspose.Note for Java x.x will be displayed against these fields.

Exporting Notebook to PDF

Exporting Notebook to PDF with Options

Export to PDF as a Flattened Notebook

Aspose.Note API can be used to export a OneNote notebook as a Flattened PDF which exports all children to a single directory.

Retrieve Documents from OneNote Notebook

The following code snippet demonstrates how to get all documents which are presented in the entire MS OneNote notebook including child notebooks.

Read RichText Nodes from Microsoft OneNote Notebook

The following code snippet demonstrates how to print all RichText nodes from MS OneNote notebook: