在 Word 文档中使用 Group 形状

Contents
[ ]

有时您需要将 group shape 添加到 Word 文档中。这样的 group shape 由多种形状组成。

在 Microsoft Word 中,您可以使用 Group 命令/按钮快速添加 group shape。组中的单个形状可以单独移动。

在 Aspose.Words 中,使用 GroupShape 类添加 group shape 非常容易。形状是使用 Shape 类单独创建的,然后使用 append_child 方法添加到 GroupShape 对象中。

以下代码示例演示如何将 group shape 添加到 Word 文档中:

# 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")