A watermark identifies the state of the document with texts like confidential, draft, etc., and makes it difficult for the original document to be copied. Watermarks are also used to specify the ownership of a document by showing the company name or logo. Watermarks in PowerPoint files can be both image or text-based. In this article, you will learn how to add text and image watermarks to PowerPoint slides using C++.
- C++ API for Adding Watermark to PowerPoint Slides
- Add Text Watermark to PowerPoint Slides using C++
- Add Image Watermark to PowerPoint Slides
C++ API for Adding Watermark to PowerPoint PPT Slides
We will use the Aspose.Slides for C++ API to add watermark to PowerPoint slides. It is a robust and feature-rich API that supports creating, reading, and updating 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
Add Text Watermark to PowerPoint Slides in C++
You can add a text watermark to PowerPoint slides by following the steps given below.
- Firstly, load the PowerPoint file using the Presentation class.
- Retrieve the master slide.
- Calculate the position of the watermark.
- Add a shape using the IMasterSlide->get_Shapes()->AddAutoShape(ShapeType shapeType, float x, float y, float width, float height) method.
- Add text frame to the shape using the IAutoShape->AddTextFrame(System::String text) method.
- Set the font size, color, and rotation angle of the watermark.
- Lock the watermark so that it cannot be moved or removed.
- Finally, save the PowerPoint file using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to add text watermarks to PowerPoint slides using C++.
Add Image Watermark to PowerPoint PPT Slides in C++
To add an image watermark to PowerPoint slides, please follow the steps given below.
- Firstly, load the PowerPoint file using the Presentation class.
- Retrieve the master slide.
- Calculate the position of the watermark.
- Add a shape using the IMasterSlide->get_Shapes()->AddAutoShape(ShapeType shapeType, float x, float y, float width, float height) method.
- Add the image and get its reference in an IPPImage object.
- Set the watermark image using the IAutoShape->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(System::SharedPtr value) method.
- Set the fill type and picture fill mode of the IAutoShape to FillType::Picture and PictureFillMode::Stretch, respectively.
- Lock the watermark so that it cannot be moved or removed.
- Finally, save the PowerPoint file using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to add an image watermark to PowerPoint slides using C++.
C++ Add Watermark to PowerPoint PPT - Get a Free License
You can get a free temporary license and add watermark to PowerPoint PPT slides without evaluation limitations.
Conclusion
In this article, you have learned how to add a watermark to PowerPoint slides using C++. The shared code samples show how to easily add image and text watermarks to PowerPoint slides using the Aspose.Slides to C++ API.
PowerPoint Watermarking API for C++ - Read More
Aspose.Slides for C++ is a powerful API that provides a bunch of additional features for working with PowerPoint PPTX/PPT 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
- Apply Animation to Text in PowerPoint using C++
- Create SmartArt in PowerPoint Presentations using C++
Info: You may want to check out Aspose.Slides free Add Watermark to PowerPoint and Remove Watermark from PowerPoint online tools.