Presentation — Aspose.Slides FOSS for Java API Reference

The Presentation class is the root object for creating, loading, and saving PowerPoint .pptx files in Aspose.Slides FOSS for Java. It implements IPresentation.

Package: org.aspose.slides.foss

import org.aspose.slides.foss.*;
public class Presentation implements IPresentation

Inheritance

IPresentation -> Presentation


Constructors

SignatureDescription
Presentation()Create a new blank presentation with one slide.
Presentation(String path)Open a presentation from the given file path.
Presentation(InputStream in)Open a presentation from the given input stream.

Examples:

import org.aspose.slides.foss.*;

// Create a new empty presentation
Presentation prs = new Presentation();

// Open an existing PPTX file
Presentation prs2 = new Presentation("deck.pptx");

// Load from a stream
InputStream stream = new FileInputStream("deck.pptx");
Presentation prs3 = new Presentation(stream);

Properties

PropertyTypeAccessDescription
getSlides()ISlideCollectionReadOrdered collection of slides in the presentation.
getMasters()IMasterSlideCollectionReadCollection of master slides.
getLayoutSlides()IGlobalLayoutSlideCollectionReadCollection of all layout slides across all masters.
getCommentAuthors()ICommentAuthorCollectionReadCollection of comment authors.
getDocumentProperties()IDocumentPropertiesReadCore, application, and custom document metadata.
getImages()IImageCollectionReadCollection of all images embedded in the presentation.
getNotesSize()INotesSizeReadNotes slide size settings.
getSourceFormat()SourceFormatReadFormat of the loaded presentation source.
getCurrentDateTime() / setCurrentDateTime(LocalDateTime)LocalDateTimeRead/WriteDate and time used for date-time placeholders.
getFirstSlideNumber() / setFirstSlideNumber(int)intRead/WriteFirst slide number in the presentation.

Methods

save(String path)

Save the presentation to a file (default PPTX format).

ParameterTypeDescription
pathStringDestination file path.
prs.save("output.pptx");

save(OutputStream stream)

Save the presentation to an output stream.

ParameterTypeDescription
streamOutputStreamDestination stream.

save(String path, SaveFormat format)

Save the presentation to a file in the specified format.

ParameterTypeDescription
pathStringDestination file path.
formatSaveFormatOutput format (e.g., SaveFormat.PPTX).
prs.save("output.pptx", SaveFormat.PPTX);

save(OutputStream stream, SaveFormat format)

Save the presentation to a stream in the specified format.

save(String path, SaveFormat format, ISaveOptions options)

Save the presentation to a file with additional options.

ParameterTypeDescription
pathStringDestination file path.
formatSaveFormatOutput format.
optionsISaveOptionsSave options controlling output behavior.

Usage Examples

Create a Presentation with a Shape

import org.aspose.slides.foss.*;

Presentation prs = new Presentation();
ISlide slide = prs.getSlides().get(0);
IAutoShape shape = slide.getShapes().addAutoShape(
    ShapeType.RECTANGLE, 50, 50, 300, 100);
shape.addTextFrame("Hello, Slides!");
prs.save("hello.pptx", SaveFormat.PPTX);

Open, Inspect, and Re-Save

import org.aspose.slides.foss.*;

Presentation prs = new Presentation("existing.pptx");
System.out.println("Slides: " + prs.getSlides().size());
for (int i = 0; i < prs.getSlides().size(); i++) {
    ISlide slide = prs.getSlides().get(i);
    System.out.println("  Slide " + i + ": " + slide.getShapes().size() + " shapes");
}
prs.save("existing-updated.pptx", SaveFormat.PPTX);

Set Document Properties

import org.aspose.slides.foss.*;

Presentation prs = new Presentation();
prs.getDocumentProperties().setTitle("Q1 Results");
prs.getDocumentProperties().setAuthor("Finance Team");
prs.getDocumentProperties().setSubject("Quarterly Review");
prs.save("q1.pptx", SaveFormat.PPTX);

See Also