世俱杯 2025

Word处理控件Aspose.Words功能演示:使用 C++ 将 PowerPoint 演示文稿转换为 Word 文档

翻译|使用教程|编辑:胡涛|2022-07-22 10:14:01.200|阅读 147 次

概述:本文将介绍如何使用 C++ 将 PowerPoint 演示文稿转换为 Word 文档,欢迎查阅!

# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>

相关链接:

使用 C++ 将 PowerPoint 演示文稿转换为 Word 文档

 在某些情况下,您有一个 PowerPoint 演示文稿并想要创建一个详细描述其内容的文档。为此,您可以将PPTX文件转换为 Word 格式并修改 Word 文件以输入每张幻灯片的详细信息。在本文中,您将学习如何使用 C++ 以编程方式将 PowerPoint PPTX/PPT 文件转换为 Word 格式。

Aspose.Words 最新下载

用于将 PowerPoint 文件转换为 Word 格式的 C++ API

 为了将 PowerPoint 演示文稿转换为 Word 文档,我们将使用Aspose.Slides for C++和Aspose.Words for C++ APIs。前者是用于处理 PowerPoint 文件的 API,而后者用于创建、读取和修改 Word 文档。我们将使用 Aspose.Slides for C++ API 将 PowerPoint 文件转换为 HTML 格式,并使用 Aspose.Words for C++ API 将生成的 HTML 转换为 Word 格式。您可以通过 NuGet 安装 API,也可以直接从“下载”部分下载它们。


PM> Install-Package Aspose.Slides.Cpp
PM> Install-Package Aspose.Words.Cpp


使用 C++ 将 PowerPoint PPTX/PPT 文件转换为 DOCX 格式

 以下是使用 C++ 将 PowerPoint PPTX/PPT 文件转换为 DOCX 格式的步骤。

  • 使用Aspose::Slides::Presentation类加载 PowerPoint 文件。
  • 创建MemoryStream类的实例。
  • 将演示文稿保存到流中。
  • 使用流对象创建Aspose::Words::Document类的实例。
  • 使用Aspose::Words::Document->Save(const System::String & fileName, Aspose::Words::SaveFormat saveFormat)方法保存 DOCX 文件。

 以下示例代码展示了如何使用 C++ 将 PowerPoint PPTX/PPT 文件转换为 DOCX 格式。

// File paths
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\SlidesToWord_out.docx";

// Load the presentation file
auto presentation = System::MakeObject<Aspose::Slides::Presentation>(sourceFilePath);

// Create an instance of the MemoryStream class
auto stream = System::MakeObject<MemoryStream>();

// Save the presentation to the stream
presentation->Save(stream, SaveFormat::Html);
stream->Flush();
stream->Seek(0, SeekOrigin::Begin);

// Create an instance of the Document class using the stream
auto doc = System::MakeObject<Aspose::Words::Document>(stream);

// Save the Word document
doc->Save(outputFilePath, Aspose::Words::SaveFormat::Docx);

结论

 在本文中,您学习了如何使用 C++ 将 PowerPoint PPTX/PPT 文件转换为 Word 文档。我们使用 Aspose.Slides for C++ API 将 PPTX/PPT 文件转换为 HTML 格式,使用 Aspose.Words for C++ API 将生成的 HTML 转换为 DOCX 格式。要了解有关这些 API 的更多信息,您可以访问它们的官方文档。


欢迎下载|体验更多Aspose产品

获取更多信息请咨询 或 加入Aspose技术交流群(761297826

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@dpuzeg.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP