ImageDataImageBytes Property |
Namespace: Aspose.Words.Drawing
Setting the value to null or an empty array will remove the image from the shape.
Returns null if the image is not stored in the document (e.g the image is probably linked in this case).
Document imgSourceDoc = new Document(MyDir + "Images.docx"); // Images are stored as shapes // Get into the document's shape collection to verify that it contains 10 images List<Shape> shapes = imgSourceDoc.GetChildNodes(NodeType.Shape, true).Cast<Shape>().ToList(); Assert.AreEqual(10, shapes.Count); // ToByteArray() returns the value of the ImageBytes property Assert.AreEqual(shapes[0].ImageData.ImageBytes, shapes[0].ImageData.ToByteArray()); // Put the shape's image data into a stream // Then, put the image data from that stream into another stream which creates an image file in the local file system using (Stream imgStream = shapes[0].ImageData.ToStream()) { using (FileStream outStream = new FileStream(ArtifactsDir + "Drawing.GetDataFromImage.png", FileMode.Create)) { imgStream.CopyTo(outStream); } }