Password Protection of PowerPoint Presentations in Java

Protection is important for confidential and private documents. In this article, we will see how to lock PowerPoint presentation files with a password in Java. Further, we will learn to unlock presentation files by removing their password and also how to change the existing password of PPT & PPTX files.

Password Protect Presentations - Lock Unlock PPT-PPTX in Java

The following topics are discussed below:

Java API to Lock and Unlock PowerPoint Files

In order to deal with the protection of presentation files, we will use the Java API of GroupDocs.Merger. The API provides the add, change, and remove password protection features for presentations and other documents.

Download and Configure

Get the library from the downloads section. For your Maven-based Java application, just add the following pom.xml configuration. After this, you can try the examples of this article as well the many more example available on GitHub. For the details, you may visit the API Reference.

<repository>
	<id>GroupDocsJavaAPI</id>
	<name>GroupDocs Java API</name>
	<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
        <groupId>com.groupdocs</groupId>
        <artifactId>groupdocs-merger</artifactId>
        <version>21.9</version> 
</dependency>

Add Password to PowerPoint Files in Java – Lock PPT/PPTX

Lock PPT with Password

You can lock any presentation file easily by adding a password to it programmatically. The following steps show how to add a password to any PowerPoint presentation (PPT/PPTX) file in Java.

The following Java code snippet locks the presentation by adding a password to the PPT file.

When you try to open the output file obtained from the above code, the editor or viewer will ask for the password while opening the presentation.

Enter Password to Protected PPTX

Update Existing Password of PPT/PPTX Files in Java

If you have doubt that your password is glanced at by someone. You can change it easily. The following steps allow you to change the existing password of the presentation file in Java.

Here is the Java code snippet that changes the existing password with a new one of a PowerPoint PPT/PPTX presentation.

Remove Password of Presentation in Java – Unlock PPT/PPTX

Unlock PPT - Password Removed

Let’s remove the protection and let everyone access the file. Just, open the file and then remove its password for public access. The following steps show how to unlock the PPT file by removing the password in Java.

The following Java code sample removes the password from the PowerPoint presentation file to keep it unlocked.

Get a Free API License

You can get a free temporary license to use the API without the evaluation limitations.

Conclusion

Let’s sum up what we learned today. We used a PowerPoint presentation (PPTX) and first, we added a password to it to get it locked. Next, we changed its existing password. Lastly, we learned how to remove the password of the protected PowerPoint file in Java.

To learn more about GroupDocs.Merger for Java, visit the documentation. It will help you develop your own applications to lock and unlock presentation files. For queries, contact us via the forum.

See Also