Protect presentation slides in Java

Spire.Presentation for Java enables developers to encrypt the PowerPoint files with password, set write protection to make the presentation read only, modify the password and decrypted the presentation slides. This article will show you how to protect the presentation slides in Java applications as below:

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

Encrypt PowerPoint file

Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.pptx");

presentation.encrypt("e-iceblue");

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

Protect presentation slides in Java

Set the presentation slides read only

Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.pptx");

presentation.protect("123456");

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

Protect presentation slides in Java

Remove Encryption on Password-Protected PowerPoint File

Presentation presentation = new Presentation();
//load the encrypted document with password
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Encrypted.pptx", FileFormat.PPTX_2010,"e-iceblue");

//Remove encryption
presentation.removeEncryption();

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

Modify the password of the protected PowerPoint document

Presentation presentation = new Presentation();

//load the encrypted document with password
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\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);