Using this simple code I expect my output to be a document without that shape.
Using inStream As New MemoryStream(My.Resources.DocumentWithShape)
Dim loadDoc As New Aspose.Words.Document(inStream)
For Each shape As Aspose.Words.Drawing.Shape In loadDoc.GetChildNodes(Aspose.Words.NodeType.Shape, True)
shape.Remove()
Next
loadDoc.Save "c:\DocumentStillContainsShape.docx")
End Using
Console.WriteLine("Documents saved")
Console.ReadLine()
Yet for some reason the saved document still contains the shape.
When debugging I noticed “loadDoc.GetChildNodes(Aspose.Words.NodeType.Shape, True)” cannot find the shape that is in the document.
Thanks for your inquiry. Your document contains DrawingML node not Shape node. Please use the following code snippet to achieve you requirements.
For Each drawingML As Aspose.Words.Drawing.Shape In loadDoc.GetChildNodes(Aspose.Words.NodeType.DrawingML, True)
drawingML.Remove()
Next
DrawingML class represents a DrawingML shape, picture, chart or diagram in a document. Shape Class represents an object in the drawing layer, such as an AutoShape, textbox, freeform, OLE object, ActiveX control, or picture.
Thanks for your inquiry. The textbox in Docx is represented by DrawingML and in Doc file format it is Shape. Please save the document to Doc file format and use the same code to get the Shape nodes. Hope this answers your query. Please let us know if you have any more queries.