如何将 Group 形状添加到 Word 文档中
Contents
[
Hide
]
有时您需要将 group shape 添加到 Word 文档中。这样的 group shape 由多种形状组成。
在 Microsoft Word 中,您可以使用 Group 命令/按钮快速添加 group shape。组中的单个形状可以单独移动。
在 Aspose.Words 中,使用 GroupShape 类添加 group shape 非常容易。 Shape 使用 Shape 类单独创建,然后使用 AppendChild 方法添加到 GroupShape 对象。
以下代码示例演示如何将 group shape 添加到 Word 文档中:
This file contains 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-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir_WorkingWithDocument(); | |
Document doc = new Document(); | |
doc.EnsureMinimum(); | |
GroupShape gs = new GroupShape(doc); | |
Shape shape = new Shape(doc, Drawing.ShapeType.AccentBorderCallout1); | |
shape.Width = 100; | |
shape.Height = 100; | |
gs.AppendChild(shape); | |
Shape shape1 = new Shape(doc, Drawing.ShapeType.ActionButtonBeginning); | |
shape1.Left = 100; | |
shape1.Width = 100; | |
shape1.Height = 200; | |
gs.AppendChild(shape1); | |
gs.Width = 200; | |
gs.Height = 200; | |
gs.CoordSize = new System.Drawing.Size(200, 200); | |
DocumentBuilder builder = new DocumentBuilder(doc); | |
builder.InsertNode(gs); | |
dataDir = dataDir + "groupshape-doc_out.doc"; | |
// Save the document to disk. | |
doc.Save(dataDir); |
以下是 Aspose.Words 支持的一些 Shape
类型:
- 长方形
- 圆角矩形
- 圆角矩形
- 椭圆
- 钻石
- 三角形
- 直角三角形
- 平行四边形
- 梯形
- 六角形
- 八角形
如需完整列表,请查看 ShapeType 类。