[Java] Setting the PowerPoint Document Property MarkAsFinal as True

·

2 min read

Mark as Final means that the presentation slide is the final edition and the author doesn’t want anyone to edit or change the content inside. With Free Spire.Presentation for Java, we can protect the presentation slides by setting the document property MarkAsFinal as true. This article will share the Java code used to mark a PowerPoint document as final.

Installation

Method 1: Download the Free Spire.Presentation for Java and unzip it. Then add the Spire.Presentation.jar file to your project as dependency.

Method 2: You can also add the jar dependency to 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>2.6.1</version>
    </dependency>
</dependencies>

Java Code:

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

public class MarkAsFinal {
    public static void main(String[] args) throws Exception {

        //Create a PPT document and load file
        Presentation presentation = new Presentation();
        presentation.loadFromFile("test.pptx");

        //Set the document property MarkAsFinal as true
        presentation.getDocumentProperty().set("_MarkAsFinal", true);

        //Save the document to file
        presentation.saveToFile("MarkasFinal.pptx", FileFormat.PPTX_2010);
    }
}

Output:

ppt.png