How to Add Group Shape into a Word Document
Sometimes you need to add a group shape into a Word document. Such a group shape consists of multiple shapes.
In Microsoft Word, you can quickly add a group shape using the Group command/button. An individual shape in a group can be moved separately.
In Aspose.Words it is very easy to add a group shape using the GroupShape class. Shape is created separately using the Shape class and then added to the GroupShape object using the AppendChild method.
The following code example shows how to add a group shape into a Word document:
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(); | |
doc.EnsureMinimum(); | |
GroupShape groupShape = new GroupShape(doc); | |
Shape accentBorderShape = new Shape(doc, ShapeType.AccentBorderCallout1) { Width = 100, Height = 100 }; | |
groupShape.AppendChild(accentBorderShape); | |
Shape actionButtonShape = new Shape(doc, ShapeType.ActionButtonBeginning) | |
{ | |
Left = 100, Width = 100, Height = 200 | |
}; | |
groupShape.AppendChild(actionButtonShape); | |
groupShape.Width = 200; | |
groupShape.Height = 200; | |
groupShape.CoordSize = new Size(200, 200); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.InsertNode(groupShape); | |
doc.Save(ArtifactsDir + "WorkingWithShapes.AddGroupShape.docx"); |
Below are some of the Shape
types supported in Aspose.Words:
- Rectangle
- RoundRectangle
- RoundRectangle
- Ellipse
- Diamond
- Triangle
- RightTriangle
- Parallelogram
- Trapezoid
- Hexagon
- Octagon
For complete list, please check the ShapeType class.