Word文書でのGroup Shapesの操作

Contents
[ ]

場合によっては、Word文書にgroup shapeを追加する必要があります。 このようなgroup shapeは複数の図形で構成されます。

Microsoft Wordでは、グループコマンド/ボタンを使用してgroup shapeをすばやく追加できます。 グループ内の個々の図形は、個別に移動できます。

Aspose.Wordsでは、GroupShapeクラスを使用してgroup shapeを追加するのは非常に簡単です。 図形はShapeクラスを使用して個別に作成され、AppendChildメソッドを使用してGroupShapeオブジェクトに追加されます。

次のコード例は、Word文書にgroup shapeを追加する方法を示しています:

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);