將 PowerPoint 簡報轉換為 C++ 中的 Word 文件

簡介

如果您打算以新方式使用簡報(PPT 或 PPTX)中的文字內容或資訊,將簡報轉換為 Word(DOC 或 DOCX)可能會對您有幫助。

  • 相較於 Microsoft PowerPoint,Microsoft Word 應用程式在內容工具或功能方面更為完善。
  • 除了 Word 的編輯功能外,您還可以受惠於增強的協作、列印和分享功能。

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 支援所有簡報格式,包括 PPT、PPTX、ODP 以及其他常見檔案類型。這確保您能使用各版本 Microsoft PowerPoint 所建立的簡報。