Find Replace Text OneNote

OneNote files can be used to organize different tasks. For example, planning your trips, some checklist, or brainstorming. Moreover, you may need to find or replace text in a OneNote Document sometimes. Let us explore the following topics:

Search and Replace Text in OneNote File – Java API Installation

Aspose.Note for Java API lets you create, convert, or manipulate .one files. You can quickly configure the API by downloading the JAR file from the official Downloads section, or with the following configurations in the pom.xml file of your project. It will easily download the files from Aspose Repository.

Repository:

 <repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>https://repository.aspose.com/repo/</url>
    </repository>
</repositories>

Dependency:

 <dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-note</artifactId>
        <version>21.1</version>
        <classifier>jdk17</classifier>        
    </dependency>
</dependencies>

Find and Replace Text on Specific Page of OneNote File in Java

You may use a OneNote file to keep notes, reminders, pictures etc. For textual contents, you can find and replace text in OneNote file with few simple steps as listed below:

  1. Load input OneNote file
  2. Get the list of page nodes
  3. Traverse all nodes to find text
  4. Replace text
  5. Save output .one file

The following code shows how to find and replace text on a specific page of .one file programmatically in Java:

Find and Replace Text on All Pages of OneNote File in Java

Sometimes there are several occurrences of text across multiple pages of a OneNote file. In order to find and replace text on all pages, you need to follow the steps below:

  1. Load input .one file
  2. Get all RichText nodes
  3. Traverse all nodes and compare text
  4. Replace the text
  5. Save output file

The code snippet explains how to find and replace text on all pages of OneNote file programmatically using Java:

Conclusion

In this article, we have explored how to work with OneNote files. You have learned how to find and replace text in OneNote files programmatically using Java language. Likewise, several other features are supported by the API. You can learn further features by taking a look at API Documentation. We would love to hear your feedback at Free Support Forum. Cheers!

See Also