Java adds footers to PowerPoint documents

Time:2020-12-7

preface

In the production of PowerPoint slides, you may encounter the need to add the page number, time, company name and other landmark content to the slide. At this point, we can do this by inserting the header and footers. This paper will useFree Spire.Presentation for JavaThe free control demonstrates how to add a page number, time, and company name to a PowerPoint Slide in a java program.

Test environment construction

Before running the code, you need to build a test environment. First download, install and configure JDK and IntelliJ idea, and then import the jar package in the control into idea. Here are two import methods for you.firstly, directly inOfficial websiteDownload the installation package and unzip it to the Lib folder Spire.Presentation.jar And finally import it manually into idea.secondRecommended), create a maven project in idea, and then pom.xml Type the following code into the file, and finally click “import changes.”. More detailed steps can be referred toThis tutorial

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

last,Import effectAs shown in the figure below:

Java adds footers to PowerPoint documents

Code example

import com.spire.presentation.*;
public class AddFooter {
    public static void main(String[] args) throws Exception {
        //Load ppt sample document
 Presentation presentation = new Presentation();
        presentation.loadFromFile("C:UsersTest1DesktopSample.pptx");
        //Add footers
 presentation.setFooterText (Zhengfei Media Co., Ltd.);
        //Set footers to visible
 presentation.setFooterVisible(true);
        //Set page number to visible
 presentation.setSlideNumberVisible(true);
        //Set date to visible
 presentation.setDateTimeVisible(true);
        //Save result document
 presentation.saveToFile("output/AddFooter.pptx", FileFormat.PPTX_2010);
    }
}

design sketch:

Java adds footers to PowerPoint documents