Working with Group Shape in Word Documents
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 GroupShape class. Shape is created separately using Shape class and then added in GroupShape object using append_child 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-Python-via-.NET | |
doc = aw.Document() | |
doc.ensure_minimum() | |
groupShape = aw.drawing.GroupShape(doc) | |
accentBorderShape = aw.drawing.Shape(doc, aw.drawing.ShapeType.ACCENT_BORDER_CALLOUT1) | |
accentBorderShape.width = 100 | |
accentBorderShape.height = 100 | |
groupShape.append_child(accentBorderShape) | |
actionButtonShape = aw.drawing.Shape(doc, aw.drawing.ShapeType.ACTION_BUTTON_BEGINNING) | |
actionButtonShape.left = 100 | |
actionButtonShape.width = 100 | |
actionButtonShape.height = 200 | |
groupShape.append_child(actionButtonShape) | |
groupShape.width = 200 | |
groupShape.height = 200 | |
groupShape.coord_size = drawing.Size(200, 200) | |
builder = aw.DocumentBuilder(doc) | |
builder.insert_node(groupShape) | |
doc.save(docs_base.artifacts_dir + "WorkingWithShapes.add_group_shape.docx") |
Below are some of the Shape
types supported in Aspose.Words. For complete list, please see aspose.words.drawing.ShapeType enumeration