การทำงานกับGroup Shapesในเอกสารคำ

Contents
[ ]

บางครั้งคุณต้องเพิ่มgroup shapeลงในเอกสารคำ เช่นgroup shapeประกอบด้วยหลายรูปร่าง.

ในMicrosoft Wordคุณสามารถเพิ่มgroup shapeได้อย่างรวดเร็วโดยใช้ปุ่มคำสั่ง/กลุ่ม รูปร่างของแต่ละบุคคลในกลุ่มสามารถเคลื่อนย้ายแยกต่างหาก.

ในAspose.Wordsมันเป็นเรื่องง่ายมากที่จะเพิ่มgroup shapeโดยใช้GroupShapeชั้น. รูปร่างถูกสร้างขึ้นแยกต่างหากโดยใช้ชั้นเรียนShapeแล้วเพิ่มไปยังวัตถุGroupShapeโดยใช้วิธีการAppendChild.

ตัวอย่างรหัสต่อไปนี้แสดงวิธีการเพิ่ม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);