Робота з Group Shapes в Word документах
Іноді потрібно додати group shape до документа Word. Такий group shape складається з декількох фігур.
У полі Microsoft Word ви можете швидко додати group shape за допомогою команди/кнопки “згрупувати”. Окрему фігуру в групі можна переміщати окремо.
У Aspose.Words дуже просто додати об’єкт group shape, використовуючи клас GroupShape. Фігура створюється окремо за допомогою класу Shape, а потім додається до об’єкта GroupShape за допомогою методу AppendChild.
Наступний приклад коду показує, як додати group shape до документа Word:
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); |
Нижче наведено деякі типи Shape
, які підтримуються в Aspose.Words. Для отримання повного списку, будь ласка, відвідайте ShapeType:
- Прямокутник
- RoundRectangle
- RoundRectangle
- Еліпс
- Діамант
- Трикутник
- RightTriangle
- Паралелограм
- Трапеція
- Шестикутник
- Восьмикутник