# 使用 C++ 将水印添加到 PPT 演示文件

> C++ 源代码，用于将水印添加到 PPT 演示文稿。

Source: https://products.aspose.com/slides/zh/cpp/watermark/ppt/
Updated: 2023-06-14



## 通过 C++ 为 PPT 演示文稿添加水印

使用 Aspose.Slides for C++，您可以为 PPT 演示文稿添加水印。水印是任何演示文稿的重要组成部分。它们用于保护演示文稿的内容不被复制或未经许可使用。水印是放置在演示文稿顶部的可见或不可见的图像或文本。它可用于识别演示文稿的所有者并防止未经授权的使用。水印也可用于为演示文稿增添专业气息并使其看起来更加精美。

### 使用 C++ 将文本水印添加到 PPT

```cpp

auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slides()->idx_get(0);
auto master = presentation->get_Masters()->idx_get(0);
auto watermarkShape = slide->get_Shapes()->AddAutoShape(ShapeType::Triangle, 0.0f, 0.0f, 0.0f, 0.0f);

auto watermarkTextFrame = watermarkShape->AddTextFrame(u"Watermark");
presentation->Save(u"watermark.ppt", SaveFormat::Ppt);
```

### 使用 C++ 将图像水印添加到 PPT 演示文稿

```cpp

auto presentation = System::MakeObject<Presentation>();
auto slide = presentation->get_Slides()->idx_get(0);
auto master = presentation->get_Masters()->idx_get(0);
auto watermarkShape = slide->get_Shapes()->AddAutoShape(ShapeType::Triangle, 0.0f, 0.0f, 0.0f, 0.0f);

auto image = presentation->get_Images()->AddImage(:File::ReadAllBytes(u"watermark.png"));

watermarkShape->get_FillFormat()->set_FillType(FillType::Picture);
watermarkShape->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(image);
watermarkShape->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode(PictureFillMode::Stretch);

presentation->Save(u"watermark2.ppt", SaveFormat::Ppt);
```

## 如何通过 C++ 为 PPT 添加水印

这些是将文本水印添加到 PPT 文件的步骤。

使用 Presentation 实例加载 PPT

选择主演示文稿

使用 AddAutoShape 方法添加形状类型

使用 AddTextFrame 方法添加水印文本

以 PPT 格式保存结果

## 其他支持的格式
