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
- Find and Replace Text on Specific Page of OneNote File in Java
- Find and Replace Text on All Pages of OneNote in Java
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:
- Load input OneNote file
- Get the list of page nodes
- Traverse all nodes to find text
- Replace text
- 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:
- Load input .one file
- Get all RichText nodes
- Traverse all nodes and compare text
- Replace the text
- 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!