将 DOC 转换为 POT 的 C++ API 或在线应用程序

在您的 C++ 应用程序中将 DOC 导出为 POT,而无需使用 Microsoft Word®或 PowerPoint

 

Aspose.Total for C++ 包含强大的文件自动化 API,允许在使用其中两个 API 时自动进行 DOC 到 POT 的转换。使用 Aspose.Words for C++ 加载您的 DOC 并将其转换为 HTML,然后通过 PowerPoint 操作 C++ API Aspose.Slides for C++ 加载 HTML 创建一个新的演示文稿,并将其保存为 POT。

C++ 上的 DOC 到 POT 转换

  1. Document 类参考打开DOC文件
  2. 使用 Save 成员函数将 DOC 转换为 HTML
  3. 始化一个新的 Presentation 对象
  4. 在你的幻灯片中添加一个自选图形,并在其中添加 AddTextFrame
  5. 加载 HTML 内容并将其写入您的 Presentation 文件中
  6. 使用 Save 方法将文档保存为 POT 格式,并将 Pot 设置为 SaveFormat

转换要求

从命令行安装为 nuget install Aspose.Total.Cpp 或通过 Visual Studio 的包管理器控制台使用 ```Install-Package Aspose.Total.Cpp``。

或者,从 下载 获取 ZIP 文件中的离线 MSI 安装程序或 DLL。

// load DOC file with an instance of Document
Document document = new Document("template.doc");
System::SharedPtr<Document> doc = System::MakeObject<Document>(u"sourceFile.doc");
// save the document in HTML file format
doc->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 Pot
pres->Save(output.pot, Aspose::Slides::Export::SaveFormat::Pot);                  

免费的 DOC 到 POT 在线转换器

通过 C++ 加载受密码保护的 DOC 文档

除了文档转换, Aspose.Words for C++ API 为 C++ 开发人员提供了大量的文档操作功能。如果您的 Microsoft Word DOC 文件格式受密码保护,您仍然可以使用 API 打开它。为了加载加密文档,您可以使用特殊的构造函数重载,它接受 LoadOptions 对象。此对象包含 Password 属性,该属性指定密码字符串。

// when loading password protected document, the password is passed to the document's constructor using a LoadOptions object.
auto options = MakeObject<LoadOptions>(u"docPassword");
// load the document from the local file system by filename:
SharedPtr<Document> doc = MakeObject<Document>(u"Encrypted.doc", options);

通过 C++ 在 POT 文档中添加注释

在将 DOC 保存为 POT 的同时,您还可以使用 Aspose.Slides for C++ 在您的 POT 文档中添加更多功能。例如,您可以在演示文稿中添加评论。演示幻灯片注释与特定作者相关联。 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 Pot
pres->Save(output.pot, Aspose::Slides::Export::SaveFormat::Pot);  

经常问的问题

  • 如何在线将 DOC 转换为 POT?
    您可以在上面找到用于 DOC 转换的在线应用程序。要开始转换过程,您可以通过拖放 DOC 文件或在白色区域内单击以导入文档来添加 DOC 文件。添加文件后,只需单击“转换”按钮即可。 DOC 到 POT 转换完成后,您只需单击一下即可下载转换后的文件。
  • 转换 DOC 需要多长时间?
    此在线转换器的速度在很大程度上取决于正在转换的 DOC 文件的大小。只需几秒钟即可将小型 DOC 文件转换为 POT。如果您在 C++ 应用程序中使用转换代码,转换速度将取决于您对应用程序的优化程度。
  • 使用免费的 Aspose.Total 转换器将 DOC 转换为 POT 是否安全?
    当然!使用我们的在线转换器将您的 DOC 文件转换为 POT 后,POT 文件的下载链接将立即可用。我们非常重视您上传文件的安全和隐私,并会在转换过程完成 24 小时后将其删除。请放心,没有人可以访问您的文件。我们的转换过程,包括 DOC 转换,是完全安全的。我们提供了一个用于测试目的的免费应用程序,以便您可以在集成代码之前验证结果。
  • 我应该使用什么浏览器来转换 DOC?
    对于在线 DOC 转换,您可以使用任何现代浏览器,例如 Google Chrome、Firefox、Opera 或 Safari。但是,如果您正在开发桌面应用程序,建议使用 Aspose.Total DOC Conversion API 以获得流畅的性能。

使用C++探索DOC转换选项

将DOC转换为ODP (OpenDocument 演示文稿格式)
将DOC转换为POTM (Microsoft PowerPoint 模板文件)
将DOC转换为POTX (Microsoft PowerPoint 模板演示)
将DOC转换为PPTX (打开 XML 表示格式)
将DOC转换为PPS (PowerPoint 幻灯片放映)
将DOC转换为PPSM (启用宏的幻灯片放映)
将DOC转换为PPSX (PowerPoint 幻灯片放映)
将DOC转换为PPT (PowerPoint演示文稿)
将DOC转换为PPTM (启用宏的演示文稿文件)
将DOC转换为PPTX (打开 XML 表示格式)
将DOC转换为CSV (逗号分隔值)
将DOC转换为DIF (数据交换格式)
将DOC转换为EXCEL (电子表格文件格式)
将DOC转换为FODS (OpenDocument 平面 XML 电子表格)
将DOC转换为JSON (JavaScript 对象表示法文件)
将DOC转换为ODS (OpenDocument电子表格)
将DOC转换为SXC (StarSuite Calc 电子表格)
将DOC转换为TSV (制表符分隔值)
将DOC转换为XLAM (Excel 启用宏的加载项)
将DOC转换为XLS (Microsoft Excel 二进制格式)
将DOC转换为XLSB (Excel 二进制工作簿)
将DOC转换为XLSM (启用宏的电子表格)
将DOC转换为XLSX (打开 XML 工作簿)
将DOC转换为XLT (Excel 97 - 2003 模板)
将DOC转换为XLTM (Excel 启用宏的模板)
将DOC转换为XLTX (Excel模板)