Get Number of Pages from the OneNote Document

Aspose.Note for .NET supports retrieving the number of pages from a OneNote document.

This example works as follows:

  1. Create an object of the Document class.
  2. Call Document class’ GetChildNodes method.
  3. Get a list of page nodes.
  4. Get the number of pages via Count property.
  5. Display the count on the output screen.

The following code snippet demonstrates how to get the number of pages from a OneNote file

Get Information of Each Page from the OneNote Document

The Page class provides all the properties related to a page of a OneNote document. All the pages of the OneNote file are contained by page nodes of the Document object.

The following code example demonstrates how to get information about each page in a OneNote document.

Create a OneNote Document with Root and Sub Level Pages

This topic explains how developers can generate OneNote document including various pages at root or sub-level positions. Aspose.Note APIs lets the developer to programmatically choose the level of the page.

Generating Root and Sub Level Pages in OneNote

Please see a brief description to create a OneNote document using the Aspose.Note APIs:

  1. Create an instance of the Document class that represents a OneNote document.
  2. Initialize three objects of Page class and set their levels.
  3. Initialize separate objects of Outline, OutlineElement, and RichText classes for each Page object by passing the Document class object. Calling the AppendChild method of the OutlineElement, Outline, Page, and Document classes adds an appropriate new node that can be further used to add other nodes to the OneNote document.
  4. The TextStyle class defines the text formatting.
  5. Generate the OneNote document by calling the Save method of the Document object.

Working with Page Revision Information

Working with Page History

Get All Revisions of a Specific Page

Aspose.Note for .NET APIs provide support to get the history of a specific Page, e.g. how many times a page is updated, content tracking changes, and much more. All the pages of the OneNote file are contained by page nodes of the Document object.

The following code example demonstrates how to get a particular Page and then get its history revisions detail.

Roll Back to Previous Page Version

In order to roll back to a previous page version, the latest page needs to be removed from the document and the one before this one needs to be restored to the document as shown in the following code sample.

Push Current Page Version to History

The current page can be added to history by cloning it using the Page.Clone method.

Modify Page History

The current page can be added to history by cloning it using the Page.Clone method.

Working with Conflict Pages

A document can have pages with conflict pages in its history. Such pages are not saved to document by default. Aspose.Note API lets you manipulate such a page history using the IsConflictPage property of history page as shown below.

Cloning Page with History