在Word文档中使用Group Shapes
Contents
[
Hide
]
有时您需要在Word文档中添加group shape。 这样的group shape由多个形状组成。
在Microsoft Word中,您可以使用组命令/按钮快速添加group shape。 组中的单个形状可以单独移动。
在Aspose.Words中,使用GroupShape类添加group shape非常容易。 形状使用Shape类单独创建,然后使用AppendChild方法添加到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-C | |
// The path to the documents directory. | |
System::String outputDataDir = GetOutputDataDir_WorkingWithDocument(); | |
System::SharedPtr<Document> doc = System::MakeObject<Document>(); | |
doc->EnsureMinimum(); | |
System::SharedPtr<GroupShape> gs = System::MakeObject<GroupShape>(doc); | |
System::SharedPtr<Shape> shape = System::MakeObject<Shape>(doc, ShapeType::AccentBorderCallout1); | |
shape->set_Width(100); | |
shape->set_Height(100); | |
gs->AppendChild(shape); | |
System::SharedPtr<Shape> shape1 = System::MakeObject<Shape>(doc, ShapeType::ActionButtonBeginning); | |
shape1->set_Left(100); | |
shape1->set_Width(100); | |
shape1->set_Height(200); | |
gs->AppendChild(shape1); | |
gs->set_Width(200); | |
gs->set_Height(200); | |
gs->set_CoordSize(System::Drawing::Size(200, 200)); | |
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc); | |
builder->InsertNode(gs); | |
System::String outputPath = outputDataDir + u"AddGroupShapeToDocument.doc"; | |
// Save the document to disk. | |
doc->Save(outputPath); |
下面是Aspose.Words中支持的一些Shape
类型。 有关完整列表,请访问ShapeType:
- 矩形
- RoundRectangle
- RoundRectangle
- 椭圆
- 钻石
- 三角形
- RightTriangle
- 平行四边形
- 梯形,梯形
- 六边形
- 八角,八角