在 C++ 中将 PowerPoint 演示文稿转换为 Word 文档
Contents
[
Hide
]
如果您计划以新的方式使用演示文稿(PPT 或 PPTX)中的文本内容或信息,将演示文稿转换为 Word(DOC 或 DOCX)可能会带来好处。
- 与 Microsoft PowerPoint 相比,Microsoft Word 应用在内容工具或功能方面更为完善。
- 除了 Word 的编辑功能外,您还可以受益于增强的协作、打印和共享功能。
您可能想试用我们的Presentation to Word Online Converter来看看从幻灯片的文本内容工作能获得什么收益。
Aspose.Slides 和 Aspose.Words
要将 PowerPoint 文件(PPTX 或 PPT)转换为 Word(DOCX 或 DOC),您需要同时使用 Aspose.Slides for C++ 和 Aspose.Words for C++。
作为独立的 API,Aspose.Slides for C++ 提供了可从演示文稿中提取文本的功能。
Aspose.Words 是一个高级文档处理 API,允许应用程序生成、修改、转换、渲染、打印文件以及在不使用 Microsoft Word 的情况下执行其他文档操作。
将 PowerPoint 演示文稿转换为 Word 文档
使用以下代码片段将 PowerPoint 转换为 Word:
auto presentation = MakeObject<Presentation>();
auto doc = MakeObject<Aspose::Words::Document>();
auto builder = MakeObject<Aspose::Words::DocumentBuilder>(doc);
for (const auto& slide : presentation->get_Slides())
{
// 生成并插入幻灯片图像
auto image = slide->GetImage(1.0f, 1.0f);
builder->InsertImage(image);
// 插入幻灯片文本
for (const auto& shape : slide->get_Shapes())
{
if (ObjectExt::Is<AutoShape>(shape))
{
auto autoShape = System::AsCast<AutoShape>(shape);
builder->Writeln(autoShape->get_TextFrame()->get_Text());
}
}
builder->InsertBreak(Aspose::Words::BreakType::PageBreak);
}
常见问题
需要安装哪些组件才能将 PowerPoint 和 OpenDocument 演示文稿转换为 Word 文档?
您只需在项目中添加相应的 Aspose.Slides for C++ 和 Aspose.Words for C++ 包即可。两个库均作为独立的 API 工作,不需要安装 Microsoft Office。
是否支持所有 PowerPoint 和 OpenDocument 演示稿格式?
Aspose.Slides supports all presentation formats,包括 PPT、PPTX、ODP 等常见文件类型。这确保您能够处理在不同版本的 Microsoft PowerPoint 中创建的演示稿。