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

PPTX 到 DOCX C#

用于 PowerPoint 到 Word 转换的 API

为了将 PowerPoint 演示文稿转换为 Word 文档,我们将结合使用Aspose.Slides for .NET和Aspose.Words for .NET。前者是一个演示文稿操作 API,可让您创建或修改 PowerPoint 演示文稿。而后者是用于生成或处理 Word 文档的文字处理 API。您可以下载API 或使用 NuGet 安装它们。此外,您还可以获得 Aspose.Total for .NET 的完整 Aspose API 包。

PM> Install-Package Aspose.Slides.NETPM> Install-Package Aspose.Words
在 C# 中将 PowerPoint PPTX 或 PPT 转换为 DOCX

以下是使用 C# 将 PowerPoint 演示文稿转换为 Word 文档的步骤。

  • 首先,将 Aspose.Words for .NET 和 Aspose.Slides for .NET 的引用添加到您的项目中。
  • 之后,使用Aspose.Slides.Presentation类加载 PowerPoint 演示文稿。
  • 然后,将演示文稿保存到MemoryStream对象中。
  • 创建类的对象并使用MemoryStream对象对其进行初始化。
  • 最后,使用Aspose.Words.Aspose.Words.DocumentDocument.Save(string, Aspose.Words.SaveFormat.Docx)方法保存文档。

以下代码示例展示了如何使用 C# 将 PPTX 转换为 DOCX。

// Load the PowerPoint presentationusing(Aspose.Slides.Presentation presentation = new Aspose.Slides.Presentation("pres.pptx")){using (var stream = new MemoryStream()){// Save presentation to memory streampresentation.Save(stream, SaveFormat.Html);stream.Flush();stream.Seek(0, SeekOrigin.Begin);// Load the content of the presentation to a Word documentvar doc = new Aspose.Words.Document(stream);// Save the Word documentdoc.Save("pres.docx", Aspose.Words.SaveFormat.Docx);}}
结论

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

获取更多信息请咨询在线客服 或 加入Aspose技术交流群(
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年7月1日
下一篇 2022年7月1日

相关推荐

发表回复

登录后才能评论