Set Slide Background in PowerPoint Presentations using C++

Microsoft PowerPoint provides the option to set the background of PowerPoint slides according to your needs. There might be situations where you need to set the background of PowerPoint slides programmatically. To that end, this article will teach you how to set the background of PowerPoint slides using C++. Specifically, you will learn how to set solid color, gradient, and image backgrounds.

C++ API for Setting Slide Background in PowerPoint Presentations

We will use the Aspose.Slides for C++ API to set slide background in Powerpoint presentations. It is a robust and feature-rich API that supports creating, reading, and modifying PowerPoint files without requiring additional software. You can either install the API through NuGet or download it directly from the Downloads section.

PM> Install-Package Aspose.Slides.Cpp

Set Background Color of Normal Slides using C++

The following are the steps to set the background color of a normal slide using C++.

The following sample code shows how to set the background color of normal slides using C++.

Given below is the image of the slide before setting the background color.

image of the slide before setting the background

The following is the image of the slide after setting the background color.

Image of the output generated by the sample code

Set Background Color of Master Slide using C++

In order to set the background color of the Master slide, follow the steps given below.

The following sample code shows how to set the background color of the master slide using C++.

Image of the output generated by the sample code
Image of the output generated by the sample code

Setting Gradient Background Color of Slides using C++

Instead of using solid colors, you can also apply gradient background color to PowerPoint slides. In order to achieve that, please follow the steps given below.

The following sample code shows how to set the gradient background color of slides using C++.

Image of the output generated by the sample code
Image of the output generated by the sample code

Set Image as Slide Background using C++

In order to use an image as a slide background, follow the step given below.

The following sample code shows how to set an image as a slide background using C++.

Image of the output generated by the sample code

Get a Free License

In order to try the API without evaluation limitations, you can request a free temporary license.

Conclusion

In this article, you have learned how to set the background of PowerPoint slides using C++. Specifically, you have learned how to set solid color, gradient, and image backgrounds using Aspose.Slides for C++ API. It is a powerful API that provides a bunch of additional features for working with PowerPoint files. You can explore the API in detail by visiting the official documentation. In case of any queries, please feel free to reach us at our free support forum.

See Also