您是一名 C++ 开发人员,希望在您的 C++ 应用程序中添加集成 PS 到 OTP 转换功能吗?您可以通过两个简单的步骤来完成。您可以使用 Aspose.PDF for C++ 将 PS 导出到 PPTX。其次,通过使用 Aspose.Slides for C++ ,您可以将PPTX转换为OTP。这两个 API 都属于 Aspose.Total for C++ 包。
用于将 PS 导出为 OTP 的 C++ API
- 用 Document 类参考打开PS文件
- 使用 Save 方法函数将PS转换为PPTX
- 用 Presentation 类参考加载PPTX文档
- 使用
Save
成员函数将文档保存为 OTP 格式,并将
Otp
设置为 SaveFormat
转换要求
从命令行安装为 nuget install Aspose.Total.Cpp
或通过 Visual Studio 的包管理器控制台使用 ```Install-Package Aspose.Total.Cpp``。
或者,从 下载 获取 ZIP 文件中的离线 MSI 安装程序或 DLL。
// load PS file with an instance of Document class
auto doc = MakeObject<Document>(u"template.ps");
// save PS as PPTX format
doc->Save(u"PptxOutput.pptx", SaveFormat::Pptx);
// instantiate a Presentation object that represents a PPTX file
SharedPtr<Presentation> prs = MakeObject<Presentation>(u"PptxOutput.pptx");
// save the presentation as Otp format
prs->Save(u"output.otp", Aspose::Slides::Export::SaveFormat::Otp);
通过 C++ 更改 PS 文档的密码
在将 PS 渲染为 OTP 的过程中,您可以打开受密码保护的 PS 并更改其密码。要更改 PS 文件的密码,您必须知道该文档的所有者密码。您可以通过指定所有者密码并使用 ChangePasswords 方法更改密码来使用 Aspose.PDF for C++ 加载受密码保护的 PDF 文档。
// load an existing PS Document
auto doc = MakeObject<Document>(L"input.ps", L"owner");
// change password of PS Document
doc->ChangePasswords(L"owner", L"newuser", L"newuser");
// save the document
doc->Save(L"output.Doc");
通过 C++ 在 OTP 文件中添加来自 Web 的图像
将 PS 转换为 OTP 后,您还可以将 Web 中的图像添加到输出文档中。 Aspose.Slides for C++ 支持对以下流行格式的图像进行操作:JPEG、PNG、BMP、GIF 等。您可以将计算机上的一个或多个图像添加到演示文稿的幻灯片中。此 C++ 示例代码向您展示如何将图像添加到 OTP 文件
// instantiate a Presentation object that represents a OTP file
auto pres = System::MakeObject<Presentation>("output.otp");
// get slide
auto slide = pres->get_Slides()->idx_get(0);
// initialize Web Client
auto webClient = System::MakeObject<WebClient>();
// get image data
auto imageData = webClient->DownloadData(System::MakeObject<Uri>(u"[REPLACE WITH URL]"));
// add image
auto image = pres->get_Images()->AddImage(imageData);
// add picture frame
slide->get_Shapes()->AddPictureFrame(ShapeType::Rectangle, 10.0f, 10.0f, 100.0f, 100.0f, image);
// save updated file
pres->Save(u"updated.otp", SaveFormat::Otp);