Merge OneNote Notebooks using Java

This quick guide covers how to merge OneNote notebooks using Java. It discusses the Java IDE setup, the stepwise process, and a runnable sample code to combine OneNote notebooks using Java. Moreover, you will also explore merging notebooks into different formats.

Steps to Merge OneNote Notebooks using Java

  1. Configure the IDE by installing Aspose.Note for Java to merge notebooks
  2. Load the source .ONE notebook using the Document class
  3. Access the target notebook with another object of the Document class
  4. Loop through each page while cloning it
  5. Write the merged output notebook as PDF using the save method

The steps above present how without using Microsoft OneNote combine pages using Java. You can initiate the process by accessing the input and target notebooks and then merging all the pages while cloning them. Finally, export the merged output file to a stream or disk based on your requirements.

Code to Merge OneNote Notebooks using Java

import com.aspose.note.*;
public class Main
{
public static void main(String[] args) throws Exception // Merge Note files in Java
{
// Set the licenses
new License().setLicense("License.lic");
// Load the OneNote file
com.aspose.note.Document oneSource = new com.aspose.note.Document("Aspose.one");
// Load the destination OneNote file
com.aspose.note.Document oneDestination = new com.aspose.note.Document("Aspose.one");
// Clone each page of the input file
for (com.aspose.note.Page page: oneSource) {
oneDestination.appendChildLast(page.deepClone()); }
// Save Merged OneNote document as PDF
oneDestination.save("Merged.pdf" , com.aspose.note.SaveFormat.Pdf);
System.out.println("Done");
}
}

By following this code, without using MS OneNote combine notebooks in Java. However, you can improvise the OneNote notebooks merging process by merging several notebooks, working with selective pages, or rendering different output file formats like .PDF, .ONE, .HTML,and .PNG using the SaveFormat enumeration.

This guide has helped us understand the process of combining notebooks in OneNote using Java. However, you can further explore other features like rendering .ONE file to HTML by finding the information on how to convert OneNote file to HTML using Java.

 English