Spire.Presentation for Java can be used to set passwords for PowerPoint files. This time, I will introduce how to set/cancel the password in PowerPoint.
1. From the official website of E-iceblue Free Spire. Presentation for Java Download the free version.
2. Launch the IDE to create a new project, then add the appropriate Spire. Presentation.jar to the reference that was in the installed file.
public class Protect { public static void main(String[] args) throws Exception {
//Load the file. Presentation presentation = new Presentation(); presentation.loadFromFile("C:\Users\Administrator\Desktop\Sample.pptx");
//Give a password presentation.encrypt("e-iceblue");
//you save. presentation.saveToFile("output/Encrypted.pptx", FileFormat.PPTX_2010); }
<h4> <strong> Execution result </strong> <strong> </strong> </h4>
<p><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/l/lendoris/20210120/20210120152033.png " alt="f:id:lendoris:20210120152033p:plain" title="" class="hatena-fotolife" itemprop="image" /><strong> </strong></p>
<h4> <strong> Set read password </strong> </h4>
```java
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Sample.pptx");
//Protect your files.
presentation.protect("123456");
//you save.
presentation.saveToFile("output/Readonly.pptx", FileFormat.PPTX_2010);
//Release the password. presentation.removeEncryption();
//you save. presentation.saveToFile("output/Decrypted.pptx", FileFormat.PPTX_2010);
<h4> <strong> Change password </strong> </h4>
```java
Presentation presentation = new Presentation();
presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Encrypted.pptx", FileFormat.PPTX_2010,"e-iceblue");
//Release the password.
presentation.removeEncryption();
//Reset your password.
presentation.encrypt("Newpass");
//you save.
presentation.saveToFile("output/Modifypass.pptx", FileFormat.PPTX_2010);
Recommended Posts