Java PowerPoint password setting and cancellation

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.

Preparation

1. From the official website of E-iceblue Free Spire. Presentation for Java Download the free version.

f:id:lendoris:20210120151857p:plain

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.

f:id:lendoris:20210120151914p:plain

Password setting

```java import com.spire.presentation.*;

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);

Execution result

f:id:lendoris:20210120152159p:plain

Password unlock

```java Presentation presentation = new Presentation(); presentation.loadFromFile("C:\\Users\\Administrator\\Desktop\\Encrypted.pptx", FileFormat.PPTX_2010,"e-iceblue");

//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

Java PowerPoint password setting and cancellation
Java and JavaScript
XXE and Java
Getters and setters (Java)
[Java] Thread and Runnable
Java true and false
[Java] String comparison and && and ||
Java --Serialization and Deserialization
[Java] Arguments and parameters
[Java] Password generation (Pasay)
timedatectl and Java TimeZone
[Java] Branch and repeat
[Java] Variables and types
java (classes and instances)
[Java] Overload and override
Setting method to link Java of Eclipse and Github / September 2017
Java sets the background color and background image for PowerPoint documents
Study Java # 2 (\ mark and operator)
Java version 8 and later features
Convert Java Powerpoint to XPS
[Java] Difference between == and equals
[Java] Stack area and static area
Java programming (variables and data)
Java encryption and decryption PDF
Java and Iterator Part 1 External Iterator
Create hyperlinks in Java PowerPoint
Java if and switch statements
Java class definition and instantiation
Apache Hadoop and Java 9 (Part 1)
[Java] About String and StringBuilder
[Java] HashCode and equals overrides
Insert footer in Java Powerpoint
☾ Java / Iterative statement and iterative control statement
jMetal Explanation-Algorithm setting and execution
Java methods and method overloads
java Generics T and? Difference
Advantages and disadvantages of Java
java (conditional branching and repetition)
About Java Packages and imports
[Java] Upload images and base64
C # and Java Overrides Story
Java abstract methods and classes
Java while and for statements
Java encapsulation and getters and setters