在 Word 文档中使用 Group 形状
Contents
[
Hide
]
有时您需要将 group shape 添加到 Word 文档中。这样的 group shape 由多种形状组成。
在 Microsoft Word 中,您可以使用 Group 命令/按钮快速添加 group shape。组中的单个形状可以单独移动。
在 Aspose.Words 中,使用 GroupShape 类添加 group shape 非常容易。形状是使用 Shape 类单独创建的,然后使用 append_child 方法添加到 GroupShape 对象中。
以下代码示例演示如何将 group shape 添加到 Word 文档中:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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") |
以下是 Aspose.Words 支持的一些 Shape
类型。有关完整列表,请参阅 aspose.words.drawing.ShapeType 枚举