Convert PowerPoint to Word

If you plan to use textual content or information from a presentation (PPT or PPTX) in new ways, you may benefit from converting the presentation to Word (DOC or DOCX).

  • When compared to Microsoft PowerPoint, the Microsoft Word app is more equipped with tools or functionalities for content.
  • Besides the editing functions in Word, you may also benefit from enhanced collaboration, printing, and sharing features.

Aspose.Slides and Aspose.Words

To convert a PowerPoint file (PPTX or PPT) to Word (DOCX or DOCX), you need both Aspose.Slides for Java and Aspose.Words for Java.

As a standalone API, Aspose.Slides for java provides functions that allow you to extract texts from presentations.

Aspose.Words is an advanced document processing API that allows applications to generate, modify, convert, render, print files, and perform other tasks with documents without utilizing Microsoft Word.

Convert PowerPoint to Word

  1. Download Aspose.Slides for Java and Aspose.Words for Java libraries.
  2. Add aspose-slides-x.x-jdk16.jar and aspose-words-x.x-jdk16.jar to your CLASSPATH.
  3. Use this code snippet to convert the PowerPoint to Word:
Presentation pres = new Presentation("sample.pptx");

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

for (ISlide slide : pres.getSlides()) {
    // generates a slide image as a byte array stream
    IImage image = slide.getImage(1, 1);
    ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
    image.save(imageStream, ImageFormat.Png);
    image.dispose();

    builder.insertImage(imageStream.toByteArray());

    // inserts slide's texts
    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();