OneNote files can include visual information like images or drawings in addition to text contents. In certain scenarios, you may need to insert or extract images in a OneNote document. This article explains how you can insert or extract images in a .one file in Java.
- Insert or Extract Image from OneNote .one File – Java API Installation
- Insert Image in OneNote .one File in Java
- Extract Images from OneNote .one File in Java
Insert or Extract Image in OneNote .one File – Java API Installation
You can insert or extract images in a OneNote file using Aspose.Note for Java API. You can download its JAR file from the New Releases section. Likewise, you can configure it with the following Maven specifications in the pom.xml file:
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.9</version>
<classifier>jdk17</classifier>
</dependency>
</dependencies>
Insert Image in OneNote .one File in Java
You can insert an image in a OneNote .one file by following these steps:
- Firstly, initialize LoadOptions class object.
- Load the input OneNote file with the Document class.
- Get the first page of the document and load input image.
- Set image location and alignment.
- Add the image to the page with appendChildLast method.
- Finally, save the output OneNote file.
The following code snippet shows how to insert an image in OneNote .one file in Java:
Extract Images from OneNote .one File in Java
You can extract images from a OneNote file with the below steps:
- Load the input OneNote file with the Document class.
- Get all images using getChildNodes method.
- Finally, traverse the list and save output images.
The code snippet below demonstrates how to extract images from a OneNote file in Java:
Get Free API License
You can test all the features of the API without any limitations by requesting a free evaluation license.
Conclusion
In this article, you have explored how to insert or extract images from a OneNote .one file in Java. Please visit the documentation to check several other features of the API. Moreover, please feel free to reach us out at the free support forum in case of any queries.