วิธีเพิ่มรูปร่าง Group ลงในเอกสาร Word

Contents
[ ]

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

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

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

ตัวอย่างโค้ดต่อไปนี้แสดงวิธีเพิ่ม group shape ลงในเอกสาร Word:

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