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