Convert PPTX to Word in Java

Convert PowerPoint slides to a Word document using Java code without Microsoft PowerPoint or Office

Convert PowerPoint to Word using Aspose.Slides and Aspose.Words

Aspose.Slides for Java and Aspose.Words for Java let Java applications read PowerPoint presentations and create Word documents. A PPTX to Word workflow can render each slide as an image and insert the images into a Document.

Convert PowerPoint to Word in Java

Use this Java code to convert PPTX to Word:

Java code for converting PowerPoint to Word

Presentation presentation = new Presentation("presentation.pptx");
try {
    Document document = new Document();
    DocumentBuilder documentBuilder = new DocumentBuilder(document);

    for (ISlide slide : presentation.getSlides()) {
        IImage slideImage = slide.getImage(1f, 1f);
        try {
            ByteArrayOutputStream imageStream = new ByteArrayOutputStream();
            slideImage.save(imageStream, ImageFormat.Png);
            documentBuilder.insertImage(imageStream.toByteArray());
        } finally {
            slideImage.dispose();
        }

        documentBuilder.insertBreak(BreakType.PAGE_BREAK);
    }

    document.save("output.docx");
} finally {
    presentation.dispose();
}

How to convert PPTX to Word

  1. Install Aspose.Slides for Java and Aspose.Words for Java.

  2. Load the PPTX presentation with the Presentation class.

  3. Create a Word Document and a DocumentBuilder.

  4. Render each slide with getImage and insert the image into the Word document.

  5. Save the resulting Word document.

Free Online Converter

Convert presentations and slides online.