Working with Pages

Get Number of Pages from the OneNote Document

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

This example work as follows:

  1. Create an object of the Document class.
  2. Call getChildNodes method of the Document class.
  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 shows you 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 code below shows how to get information about each page in a OneNote document.

Create OneNote Document with Root and Sub Level Pages

This article 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 below 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 AppendChildLast 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

There is a LoadHistory property of the LoadOptions class which tells whether the document loader should read and parse entire document history. The default value is true. In case of such a file with a huge amount of history data consider using LoadHistory=false, to decrease memory and CPU usage.

The code sample below shows how to get a particular Page and then get its history revisions detail.

Roll Back To Previous Page Version

Push Current Page Version To History

Modify Page History

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 method of history page as shown below.