public void DeleteAllImagesPreOrder()
{
Document doc = new Document(MyDir + "Image.SampleImages.doc");
Assert.AreEqual(6, doc.GetChildNodes(NodeType.Shape, true).Count);
//ExStart
//ExFor:Node.NextPreOrder
//ExSummary:Shows how to delete all images from a document using pre-order tree traversal.
Node curNode = doc;
while (curNode != null)
{
Node nextNode = curNode.NextPreOrder(doc);
if (curNode.NodeType.Equals(NodeType.Shape))
{
Shape shape = (Shape)curNode;
// Several shape types can have an image including image shapes and OLE objects.
if (shape.HasImage)
shape.Remove();
}
curNode = nextNode;
}
//ExEnd
Assert.AreEqual(1, doc.GetChildNodes(NodeType.Shape, true).Count);
doc.Save(MyDir + @"\Artifacts\Image.DeleteAllImagesPreOrder.doc");
}