Aspose.Total for C++ 包含强大的文件自动化 API,允许在使用其中两个 API 时自动进行 FLATOPC 到 PPTM 的转换。使用 Aspose.Words for C++ 加载您的 FLATOPC 并将其转换为 HTML,然后通过 PowerPoint 操作 C++ API Aspose.Slides for C++ 加载 HTML 创建一个新的演示文稿,并将其保存为 PPTM。
C++ 上的 FLATOPC 到 PPTM 转换
- 用 Flatopcument 类参考打开FLATOPC文件
- 使用 Save 成员函数将 FLATOPC 转换为 HTML
- 始化一个新的 Presentation 对象
- 在你的幻灯片中添加一个自选图形,并在其中添加 AddTextFrame
- 加载 HTML 内容并将其写入您的 Presentation 文件中
- 使用 Save 方法将文档保存为 PPTM 格式,并将 Pptm 设置为 SaveFormat
转换要求
从命令行安装为 nuget install Aspose.Total.Cpp
或通过 Visual Studio 的包管理器控制台使用 ```Install-Package Aspose.Total.Cpp``。
或者,从 下载 获取 ZIP 文件中的离线 MSI 安装程序或 DLL。
// load FLATOPC file with an instance of Flatopcument
Flatopcument flatopcument = new Flatopcument("template.flatopc");
System::SharedPtr<Flatopcument> flatopc = System::MakeObject<Flatopcument>(u"sourceFile.flatopc");
// save the flatopcument in HTML file format
flatopc->Save(u"HtmlOutput.HTML");
// load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// access first slide
SharedPtr<ISlide> sld = pres->get_Slides()->idx_get(0);
// add an AutoShape of Rectangle type
SharedPtr<IAutoShape> ashp = sld->get_Shapes()->AddAutoShape(ShapeType::Rectangle, 10, 10, 700, 500);
// reset default fill color
ashp->get_FillFormat()->set_FillType(FillType::NoFill);
// add TextFrame to the Rectangle
ashp->AddTextFrame(u" ");
// access the text frame
SharedPtr<ITextFrame> txtFrame = ashp->get_TextFrame();
// get Paragraphs collection
SharedPtr<Aspose::Slides::IParagraphCollection>ParaCollection = txtFrame->get_Paragraphs();
// clear all paragraphs in added text frame
ParaCollection->Clear();
// load the HTML file using stream reader
SharedPtr<System::IO::StreamReader> tr = MakeObject<System::IO::StreamReader>(HtmlOutput.HTML);
// add text from HTML stream reader in text frame
ParaCollection->AddFromHtml(tr->ReadToEnd());
// save presentation as Pptm
pres->Save(output.pptm, Aspose::Slides::Export::SaveFormat::Pptm);
免费的 FLATOPC 到 PPTM 在线转换器
通过 C++ 加载受密码保护的 FLATOPC 文档
除了文档转换, Aspose.Words for C++ API 为 C++ 开发人员提供了大量的文档操作功能。如果您的 Microsoft Word FLATOPC 文件格式受密码保护,您仍然可以使用 API 打开它。为了加载加密文档,您可以使用特殊的构造函数重载,它接受 LoadOptions 对象。此对象包含 Password 属性,该属性指定密码字符串。
// when loading password protected flatopcument, the password is passed to the flatopcument's constructor using a LoadOptions object.
auto options = MakeObject<LoadOptions>(u"flatopcPassword");
// load the flatopcument from the local file system by filename:
SharedPtr<Flatopcument> flatopc = MakeObject<Flatopcument>(u"Encrypted.flatopc", options);
通过 C++ 在 PPTM 文档中添加注释
在将 FLATOPC 保存为 PPTM 的同时,您还可以使用 Aspose.Slides for C++ 在您的 PPTM 文档中添加更多功能。例如,您可以在演示文稿中添加评论。演示幻灯片注释与特定作者相关联。 Presentation 类在 ICommentAuthorCollection 中保存负责添加幻灯片注释的作者集合。对于每个作者,ICommentCollection 中都有一组评论。
// instantiate Presentation class
SharedPtr<Presentation>pres = MakeObject<Presentation>();
// access first slide
SharedPtr<ILayoutSlide>layout = pres->get_LayoutSlides()->idx_get(0);
// add empty slide
pres->get_Slides()->AddEmptySlide(layout);
// adding Author
SharedPtr<ICommentAuthor> author = pres->get_CommentAuthors()->AddAuthor(u"John Doe", u"MF");
// set position of comments
System::Drawing::PointF point = System::Drawing::PointF(0.2f, 0.2f);
// add slide comment for an author on slide 1
author->get_Comments()->AddComment(u"Hello John, this is a slide comment", pres->get_Slides()->idx_get(1), point, DateTime::get_Now());
// access ISlide 1
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// save presentation as Pptm
pres->Save(output.pptm, Aspose::Slides::Export::SaveFormat::Pptm);
经常问的问题
- 如何在线将 FLATOPC 转换为 PPTM?您可以在上面找到用于 FLATOPC 转换的在线应用程序。要开始转换过程,您可以通过拖放 FLATOPC 文件或在白色区域内单击以导入文档来添加 FLATOPC 文件。添加文件后,只需单击“转换”按钮即可。 FLATOPC 到 PPTM 转换完成后,您只需单击一下即可下载转换后的文件。
- 转换 FLATOPC 需要多长时间?此在线转换器的速度在很大程度上取决于正在转换的 FLATOPC 文件的大小。只需几秒钟即可将小型 FLATOPC 文件转换为 PPTM。如果您在 C++ 应用程序中使用转换代码,转换速度将取决于您对应用程序的优化程度。
- 使用免费的 Aspose.Total 转换器将 FLATOPC 转换为 PPTM 是否安全?当然!使用我们的在线转换器将您的 FLATOPC 文件转换为 PPTM 后,PPTM 文件的下载链接将立即可用。我们非常重视您上传文件的安全和隐私,并会在转换过程完成 24 小时后将其删除。请放心,没有人可以访问您的文件。我们的转换过程,包括 FLATOPC 转换,是完全安全的。我们提供了一个用于测试目的的免费应用程序,以便您可以在集成代码之前验证结果。
- 我应该使用什么浏览器来转换 FLATOPC?对于在线 FLATOPC 转换,您可以使用任何现代浏览器,例如 Google Chrome、Firefox、Opera 或 Safari。但是,如果您正在开发桌面应用程序,建议使用 Aspose.Total FLATOPC Conversion API 以获得流畅的性能。