We collect, organize, and collaborate notes and ideas in OneNote documents. It is a sort of digital notebook used to take notes and share with other OneNote users. In certain cases, we may need to extract text or images from OneNote documents programmatically without using MS OneNote. In this article, we will learn how to extract text and images from OneNote documents using C#.
The following topics shall be covered in this article:
- OneNote Text and Image Extractor C# API
- Extract All the Text from OneNote Documents
- Get Text from Specific Pages of OneNote Documents
- Extract Images from OneNote Documents
OneNote Text and Image Extractor C# API
For extracting text and images from the OneNote document, we will be using the Aspose.Note for .NET API. It is a feature-rich OneNote document manipulation API that lets you create, read, and convert OneNote documents programmatically. Please either download the DLL of the API or install it using NuGet.
PM> Install-Package Aspose.Note
Extract All the Text from OneNote Documents
We can easily extract all the text from the OneNote document by following the steps given below:
- Firstly, load a OneNote file using the Document class.
- After that, call the GetChildNodes method with RichText as NodeType to extract text.
- Finally, show the extracted text.
The following code sample shows how to extract all the text from a OneNote file using C#.
Get Text from Specific Pages of OneNote Documents
We can extract text from specific pages of the OneNote document by following the steps given below:
- Firstly, load a OneNote file using the Document class.
- Next, call the GetChildNodes method with Page as NodeType to extract pages.
- After that, get a list of text items using the GetChildNodes method with RichText as NodeType.
- Finally, show the extracted text.
The following code sample shows how to extract text from a specific page of a OneNote file using C#.
Extract Images from OneNote Documents
We can also extract images from the OneNote document by following the steps given below:
- Firstly, load a OneNote file using the Document class.
- After that, get a list of images using the GetChildNodes method with Image as NodeType.
- Finally, show the image properties and save to local disk.
The following code sample shows how to extract images from a OneNote file using C#.
Get a Free License
You can get a free temporary license to try the library without evaluation limitations.
Conclusion
In this article, we have learned how to extract text from the OneNote document or from specific pages of the document. We have also seen how to extract images from OneNote documents programmatically. Besides, you can learn more about Aspose.Note for .NET API using the documentation. In case of any ambiguity, please feel free to contact us on the forum.