Examine Presentation
Aspose.Slides for Java allows you to examine a presentation to find out its properties and understand its behavior.
Info
The PresentationInfo and DocumentProperties classes contain the properties and methods used in operations here.Check a Presentation Format
Before working on a presentation, you may want to find out what format (PPT, PPTX, ODP, and others) the presentation is in at the moment.
You can check a presentation’s format without loading the presentation. See this Java code:
IPresentationInfo info = PresentationFactory.getInstance().getPresentationInfo("pres.pptx");
System.out.println(info.getLoadFormat()); // PPTX
IPresentationInfo info2 = PresentationFactory.getInstance().getPresentationInfo("pres.ppt");
System.out.println(info2.getLoadFormat()); // PPT
IPresentationInfo info3 = PresentationFactory.getInstance().getPresentationInfo("pres.odp");
System.out.println(info3.getLoadFormat()); // ODP
Get Presentation Properties
This Java code shows you how to get presentation properties (information about the presentation):
IPresentationInfo info = PresentationFactory.getInstance().getPresentationInfo("pres.pptx");
IDocumentProperties props = info.readDocumentProperties();
System.out.println(props.getCreatedTime());
System.out.println(props.getSubject());
System.out.println(props.getTitle());
// ..
You may want to see the properties under the DocumentProperties class.
Update Presentation Properties
Aspose.Slides provides the PresentationInfo.updateDocumentProperties method that allows you to make changes to presentation properties.
Let’s say we have a PowerPoint presentation with the document properties shown below.
This code example shows you how to edit some presentation properties:
String fileName = "sample.pptx";
IPresentationInfo info = PresentationFactory.getInstance().getPresentationInfo(fileName);
IDocumentProperties properties = info.readDocumentProperties();
properties.setTitle("My title");
properties.setLastSavedTime(new Date());
info.updateDocumentProperties(properties);
info.writeBindedPresentation(fileName);
The results of changing the document properties are shown below.
Useful Links
To get more information about a presentation and its security attributes, you may find these links useful: