Set and Get PowerPoint Slide Title using Free Java API

In PowerPoint, the title is arguably an important brief introduction to the text content of a specific slide and it gives the audience a general understanding of your main ideas. This article demonstrates how to set and get slide title in a PowerPoint document using Free Spire.Presentation for Java.

Installation (2 Methods)
● Download the Free Spire.Presentation for Java and unzip it, then add the Spire.Presentation.jar file to your project as dependency.

● Directly add the jar dependency to your maven project by adding the following configurations to the pom.xml.

<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.presentation.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>

Set Slide Title:

import com.spire.presentation.FileFormat;
import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

public class SetSlideTitle {
public static void main(String[] args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();

//Get the first slide
ISlide slide = ppt.getSlides().get(0);

//Set title for the slide
slide.setTitle("The Origin of the Renaissance ");

//Save the result document
ppt.saveToFile("SetTitle.pptx", FileFormat.PPTX_2013);
}
}

Get Slide Title:

import com.spire.presentation.ISlide;
import com.spire.presentation.Presentation;

public class GetSlideTitle {
public static void main(String[] args) throws Exception {
//Create a Presentation instance
Presentation ppt = new Presentation();

//Load a PowerPoint document
ppt.loadFromFile("SetTitle.pptx");

//Get the first slide
ISlide slide = ppt.getSlides().get(0);

//Print out the title of the slide
String tile = slide.getTitle();
System.out.println(tile);
}
}