Working with Images

Extract Images from a OneNote Document

All images are stored inside image nodes in a OneNote document.

Extract Images

To extract all images or from a OneNote document, follow these steps:

  1. Use the Document.GetChildNodes method to select all Image nodes.
  2. Iterate through the resulting Image node collections.
  3. Extract image bytes array using the Image.Bytes property.
  4. Save image bytes to a file.

The code example given below demonstrates how to extract images from a OneNote document and save them as files.

Get Information of Each Image from the OneNote Document

The Image class provides all the image properties for images in OneNote documents. All the images of the OneNote file are contained by image nodes in the Document object.

Get Information

The code example given below demonstrates how to get information about each image from a OneNote document.

Insert an Image on a OneNote Document Page

Aspose.Diagram for .NET APIs now allows inserting an image anywhere on the OneNote document.

An image can be inserted in the following ways.

Insert an Image in an Existing OneNote Document

To insert an image on a OneNote document, follow these steps:

  1. Use the Document.FirstChild property to get the first page.
  2. Use the Image class constructor to load the image.
  3. Use the Image.Width and Image.Height properties to adjust the size of the image.
  4. Use the Image.VerticalOffset and Image.HorizontalOffset properties to set the location of the image.
  5. Use the Page.AppendChild property to insert the image.
  6. Save a OneNote document.

The code example given below demonstrates how to insert an image on a OneNote document and save them as files.

Build a OneNote Document from Scratch and Insert an Image

Build a OneNote Document from the Scratch and Insert an Image using an Image Stream

This code example shows how to build a new OneNote document and insert an image using the image stream.

Support for Image Alternative Text