DEV Community 👩‍💻👨‍💻

E-iceblue Product Family
E-iceblue Product Family

Posted on

Protect presentation slides in Java

With the help of Free Spire.Presentation for Java, developers can protect the PowerPoint files with password or only allow the presentation slides to be read only, readers could not edit or change the contents on the slides. This article will show you how to protect the presentation slides in Java applications from the following three parts:

  • Encrypt the presentation slides
  • Set the presentation slides read only
  • Load an encrypted PowerPoint document and update its password

Encrypt PowerPoint file. Users have to enter the password to open and view the presentation slides.


Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");

presentation.encrypt("e-iceblue");

presentation.saveToFile("output/Encrypted.pptx", FileFormat.PPTX_2010);

Set the presentation slides read only. Users can read the presentation slides without the password. If they want to edit the presentation, it is impossible. The presentation slides have been set as read only.

Presentation presentation = new Presentation();
presentation.loadFromFile("Sample.pptx");

presentation.protect("123456");

presentation.saveToFile("output/Readonly.pptx", FileFormat.PPTX_2010);

Modify the password of the protected PowerPoint document. Update the existing password.

Presentation presentation = new Presentation();

//load the encrypted document with password
presentation.loadFromFile("Encrypted.pptx", FileFormat.PPTX_2010,"e-iceblue");

//Remove the Encryption
presentation.removeEncryption();
//Set the new password to encrypt the document
presentation.encrypt("Newpass");

presentation.saveToFile("output/Modifypass.pptx", FileFormat.PPTX_2010);

Top comments (0)

🌚 Life is too short to browse without dark mode