Arbeiten mit Group Shapes in Word-Dokumenten
Manchmal müssen Sie einem Word-Dokument eine group shape hinzufügen. Eine solche group shape besteht aus mehreren Formen.
In Microsoft Word können Sie mit dem Gruppenbefehl / der Schaltfläche schnell eine group shape hinzufügen. Eine einzelne Form in einer Gruppe kann separat verschoben werden.
In Aspose.Words ist es sehr einfach, eine group shape mit der GroupShape -Klasse hinzuzufügen. Die Form wird separat mit der Klasse Shape erstellt und dann mit der Methode AppendChild zum Objekt GroupShape hinzugefügt.
Das folgende Codebeispiel zeigt, wie Sie einem Word-Dokument eine group shape hinzufügen:
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); |
Nachfolgend sind einige der Shape
-Typen aufgeführt, die in Aspose.Words unterstützt werden. Für eine vollständige Liste besuchen Sie bitte ShapeType:
- Rechteck
- RoundRectangle
- RoundRectangle
- Ellipse
- Diamond
- Dreieck
- RightTriangle
- Parallelogramm
- Trapezförmig
- Sechseck
- Octagon