Headers and footers in PowerPoint are ideal for displaying descriptive content, such as slide numbers, author information, the date and more. This article will introduce how to add footers to a specified slide in PowerPoint using Java codes.
TOOL: Free Spire.Presentation for Java (free version)
ADD JAR FILE:
We need to get the package of the tool from the link, and then add
Spire.Presentation.jar to IDEA. Or directly import the following Maven
configurations.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>https://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>
USING THE CODE
Free Spire.Presentation for Java provides Presentation.setFooterText() method to add a footer and set
its content for a specified slide. The following are some steps to add a footer.
l Create a Presentation instance.
l Load a PowerPoint sample document using Presentation.loadFromFile() method.
l Add a footer and set its content using Presentation.setFooterText() method.
l Set footer, slide number and date visible
l Save the document using Presentation.saveToFile() method.
import com.spire.presentation.FileFormat;
import com.spire.presentation.Presentation;
public class Footer {
public static void main(String[] args) throws Exception {
//Load a PPT document
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Test1\\Desktop\\sample.pptx");
//Add footer
presentation.setFooterText("An English Poem");
//Set the footer visible
presentation.setFooterVisible(true);
//Set the page number visible
presentation.setSlideNumberVisible(true);
//Set the date visible
presentation.setDateTimeVisible(true);
//Save the document
presentation.saveToFile("output/AddFooter.pptx", FileFormat.PPTX_2010);
}
}The screenshot below shows relevant information after adding a footer
No comments:
Post a Comment