Working with Shapes in PowerPoint presentations using C++

Working with Shapes in PowerPoint presentations using C++

Microsoft PowerPoint provides you the ability to add shapes to your presentations. Shapes can be helpful in scenarios such as showing the flow of data or showing different phases of a process. You can use shapes such as ellipses, lines, rectangles, etc., and connect them using connectors. You might find yourself in scenarios where you have to add shapes to PowerPoint slides programmatically. To that end, this article will teach you how to work with shapes in PowerPoint presentations using C++.

C++ API for Working with Shapes in PowerPoint Presentations

Aspose.Slides for C++ is a native C++ library that supports creating, reading, and manipulating PowerPoint files. The API also supports working with shapes in PowerPoint presentations. You can either install the API through NuGet or download it directly from the Downloads section.

PM> Install-Package Aspose.Slides.Cpp

Add a Shape to a PowerPoint Slide

In order to add a shape, use the ISlide->get_Shapes()->AddAutoShape() method provided by the API. The following are the steps to add a shape to a PowerPoint slide.

The following is the sample code to add a shape to a PowerPoint slide using C++.

Add Shape to PowerPoint Slide

Add Connected Shapes to a PowerPoint Slide

Connectors can be used to connect shapes. In order to create a connector, you can use the ISlide->get_Shapes()->AddConnector() method. The following are the steps to add connected shapes to a PowerPoint slide.

The following is the sample code to add connected shapes to a PowerPoint slide using C++.

Add Connected Shapes to PowerPoint Slide

Clone Shapes in PowerPoint Slides

You can also clone existing shapes using the Aspose.Slides for C++ API. In order to clone a shape, use the ShapeCollection->InsertClone() method provided by the API. The following are the steps to clone shapes from one slide to another.

The following is the sample code to clone shapes in PowerPoint slides using C++.

Clone Shapes in PowerPoint Slides

Remove Shapes from PowerPoint Slides using C++

The following are the steps to remove shapes from PowerPoint slides.

The following is the sample code to remove shapes from PowerPoint slides using C++.

Supported PowerPoint Shapes

Aspose.Slides for C++ supports many shapes for you to work with. The following is a list of some of the supported shapes.

You can view the complete list of supported shapes by viewing the ShapeType enum values.

Get a Free License

You can request a free temporary license to try the API without evaluation limitations.

Conclusion

In this article, you have learned how to work with shapes in PowerPoint presentations using C++. Specifically, you have learned how to add, clone, and remove shapes from PowerPoint slides. Furthermore, you have seen how to connect shapes using a connector. In addition to working with shapes, Aspose.Slides for C++ provides many additional features for enhancing your PowerPoint presentations. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us on our free support forum.

See Also