在 Android 上將 PowerPoint 簡報轉換為 Word 文件

概觀

本文提供了開發人員使用 Aspose.Slides 與 Aspose.Words 將 PowerPoint 與 OpenDocument 簡報轉換為 Word 文件的解決方案。一步步的指南將會帶領您完成轉換過程的每個階段。

Aspose.Slides 與 Aspose.Words

若要將 PowerPoint 檔案(PPTX 或 PPT)轉換為 Word(DOCX 或 DOC),您需要同時使用 Aspose.Slides for Android via JavaAspose.Words for Android via Java

作為獨立的 API,Aspose.Slides for java 提供了可從簡報中擷取文字的功能。

Aspose.Words 是一個先進的文件處理 API,允許應用程式在不使用 Microsoft Word 的情況下生成、修改、轉換、呈現、列印檔案以及執行其他文件相關任務。

將 PowerPoint 轉換為 Word

  1. 下載 Aspose.Slides for Android via JavaAspose.Words for Java 程式庫。
  2. aspose-slides-x.x-jdk16.jaraspose-words-x.x-jdk16.jar 加入您的 CLASSPATH。
  3. 使用以下程式碼片段將 PowerPoint 轉換為 Word:
Presentation pres = new Presentation("sample.pptx");

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

for (ISlide slide : pres.getSlides()) {
    // 產生投影片圖像作為位元組陣列串流
    IImage image = slide.getImage(1, 1);
    ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
    image.save(imageStream, ImageFormat.Png);
    image.dispose();

    builder.insertImage(imageStream.toByteArray());

    // 插入投影片的文字
    for (IShape shape : slide.getShapes()) {
        if (shape instanceof AutoShape) {
            builder.writeln(((AutoShape) shape).getTextFrame().getText());
        }
    }

    builder.insertBreak(BreakType.PAGE_BREAK);
}

doc.save("output.docx");
pres.dispose();

常見問題

需要安裝哪些元件才能將 PowerPoint 與 OpenDocument 簡報轉換為 Word 文件?

您只需將適用於 Aspose.Slides for Android via JavaAspose.Words for Android via Java 的相應套件加入您的專案即可。兩個程式庫皆作為獨立的 API 運作,且不需要安裝 Microsoft Office。

是否支援所有 PowerPoint 與 OpenDocument 簡報格式?

Aspose.Slides 支援所有簡報格式,包括 PPT、PPTX、ODP 以及其他常見檔案類型。這確保您能處理由不同版本 Microsoft PowerPoint 建立的簡報。