Extract an image from an image annotation

On this page

You can extract an image from the ImageAnnotation object. To do this, call the ImageAnnotation.GetImage() method.

The following code snippet shows how to extract an image from an image annotation:

using (Annotator annotator = new Annotator("annotated_file.docx"))
{
	List<AnnotationBase> annotations = annotator.Get();
	for (int i = 0; i < annotations.Count; i++)
	{
		if (annotations[i] is ImageAnnotation imageAnnotation)
		{
			Image image = imageAnnotation.GetImage();
			image.Save($"extracted_image{i + 1}.{imageAnnotation.ImageExtension}");
		}
	}
}

On this page