通过 C++ 将文本水印添加到 PPTX
使用服务器端 API 构建您自己的 C++ 应用程序来为 PPTX 文件添加水印。
如何使用 C++ 给 PPTX 文件加水印
为了给 PPTX 文件加水印,我们将使用
API 是一个功能丰富、功能强大且易于使用的 C++ 平台文档水印 API。可以直接下载最新版本,直接打开
包管理器,搜索 Aspose.Slides.Cpp 并安装。您也可以从包管理器控制台使用以下命令。
命令
PM> Install-Package Aspose.Slides.Cpp
通过 C++ 向 PPTX 添加水印的步骤
您需要 aspose.slides.dll 在您自己的环境中尝试以下工作流程。
使用 Presentation 类的实例加载 PPTX 文件
获取第一张幻灯片
添加矩形类型的自选图形
将 TextFrame 添加到矩形
为文本框架创建段落对象
为段落创建 Portion 对象
使用 set_Text() 添加水印
保存文档
系统要求
Aspose.Slides for C++ 支持所有主要平台和操作系统。请确保您具有以下先决条件。
将水印添加到 PPTX - C++
// Load the desired PPTX File
SharedPtr<Presentation> pres = MakeObject<Presentation>(u"templatePath.pptx");
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 150, 75, 150, 50);
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// Add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// Accessing the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// Create the Paragraph object for text frame
SharedPtr<IParagraph> paragraph = txtFrame->get_Paragraphs()->idx_get(0);
// Create Portion object for paragraph
SharedPtr<IPortion> portion = paragraph->get_Portions()->idx_get(0);
portion->set_Text(u"Watermark Text Watermark Text Watermark Text");
//Adding another shape
SharedPtr<IAutoShape> ashape2 = slide->get_Shapes()->AddAutoShape(ShapeType::Triangle, 200, 365, 400, 150);
//Reorder shape
slide->get_Shapes()->Reorder(2, ashape2);
// Save PPTX to Disk
pres->Save(u"outPath.pptx", Aspose::Slides::Export::SaveFormat::Pptx);
关于 Aspose.Slides for C++ API
Aspose.Slides API 可用于读取、编写、操作 Microsoft PowerPoint 文档并将其转换为 PDF、XPS、HTML、TIFF、ODP 和各种其他格式。可以从头开始创建新文件并将其保存为相关支持的格式。 Aspose.Slides 是一个独立的 API,用于创建、解析或操作演示文稿、幻灯片和元素,它不依赖于 Microsoft 或 OpenOffice 等任何软件。Watermark PPTX via Online App
Add watermark to PPTX documents by visiting our Live Demos website . The live demo has the following benefits
PPTX 什么是PPTX文件格式
Files with PPTX extension are presentation files created with popular Microsoft PowerPoint application. Unlike the previous version of presentation file format PPT which was binary, the PPTX format is based on the Microsoft PowerPoint open XML presentation file format. A presentation file is a collection of slides where each slide can comprise of text, images, formatting, animations, and other media. These slides are presented to audience in the form of slideshows with custom presentation settings.
阅读更多