find replace text onenote

OneNote files contain digital notes that are stored in the hierarchy as different pages and sections. Such files may contain text, drawings, images, etc., for different purposes. You may need to find and replace some text in OneNote files. Instead of going through different pages or sections every time, you can easily perform the task programmatically using C# language. Please check out the following use cases for details:

Search and Replace Text in OneNote File – C# API Installation

Aspose.Note for .NET API supports creating, editing, and manipulating OneNote files. Installing the API is pretty simple as you can quickly download the DLL file from the New Releases section. Alternatively, you can configure the API from NuGet gallery with the following installation command in Microsoft Visual Studio IDE:

PM> Install-Package Aspose.Note

Find and Replace Text in all Pages of OneNote file Programmatically in C#

OneNote files can contain several pages of text, shapes, images, or drawings. Moreover, several text phrases can repeat on different pages and you may need to search and replace all instances. You need to follow the following steps to find and replace text on all pages of the OneNote file:

  1. Specify search and replace string.
  2. Load the input document using the Document class.
  3. Get all RichText nodes.
  4. Update the replaced string in the file.
  5. Save updated one note file.

The code below elaborates how to find and replace text on all pages of OneNote file (.one) programmatically using C#:

Find and Replace Text on a Specific Page of OneNote file with C#

You can find and replace specific instances of text in OneNote files. Please follow the steps below to update text on a specific page of a OneNote file:

  1. Specify find and replace string.
  2. Load the input document into Aspose.Note.
  3. Get all RichText nodes.
  4. Update text on a specific page.
  5. Save output .one file using Save method.

The following code shows how to find and replace text on a specific page in OneNote file programmatically with C#:

Conclusion

In conclusion, you have learned how to find and replace text contents in OneNote (.one) file. Moreover, you have explored different use cases related to text contents in a .one file. You can take a look at different features of the API by visiting the Documentation. Furthermore, you can always get in touch with us for discussing your use case or POC by writing to us at Free Support Forum. Happy coding!

See Also