Aspose.Slides for Java

Aspose.Slides for Java

Aspose.Slides for Java is a class library for creating, reading, editing and converting PowerPoint and OpenDocument presentations in Java applications, without Microsoft PowerPoint.

It loads and saves PPT, PPTX, PPS, POT and ODP, including macro-enabled and template variants, and exports to PDF, XPS, HTML, SVG, TIFF, Markdown and images.



Your first presentation

Aspose.Slides for Java is published in Aspose’s own Maven repository, not in Maven Central. Create a folder for a Maven project and save this pom.xml in it. It declares the repository, adds the library, and names the class to run:

<project xmlns="http://maven.apache.org/POM/4.0.0">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>hello-slides</artifactId>
    <version>1.0</version>

    <properties>
        <maven.compiler.release>11</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <exec.mainClass>HelloSlides</exec.mainClass>
    </properties>

    <repositories>
        <repository>
            <id>AsposeJavaAPI</id>
            <name>Aspose Java API</name>
            <url>https://releases.aspose.com/java/repo/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>com.aspose</groupId>
            <artifactId>aspose-slides</artifactId>
            <version>26.9</version>
            <classifier>jdk16</classifier>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.15.0</version>
            </plugin>
        </plugins>
    </build>
</project>

Save this code as src/main/java/HelloSlides.java:

import com.aspose.slides.*;

public class HelloSlides {
    public static void main(String[] args) {
        // Create a presentation. It already contains one empty slide.
        Presentation presentation = new Presentation();
        try {
            // Get the first slide.
            ISlide slide = presentation.getSlides().get_Item(0);

            // Add a cloud shape and put text in it.
            IAutoShape autoShape = slide.getShapes().addAutoShape(ShapeType.Cloud, 20, 20, 200, 80);
            autoShape.getTextFrame().setText("Hello, Aspose!");

            // Save the presentation as a PPTX file.
            presentation.save("new_presentation.pptx", SaveFormat.Pptx);
        } finally {
            presentation.dispose();
        }
    }
}

Then, with JDK 11 or later and Apache Maven installed, run this command in the project folder:

mvn compile exec:java

The program saves new_presentation.pptx in the project folder, with one slide holding a cloud shape with text. On Linux, fontconfig and at least one font must be installed; see Installation. Without a license, the saved file carries an evaluation watermark — see Licensing. For more ways to create and fill a presentation, see Create Presentations.