WriteProtectionOptions Class
Contains write protection settings.
Declaration
public class WriteProtectionOptions extends JavaObject
Remarks
Follow these steps to enable write protection:
- Create a
WriteProtectionOptionsobject and specify a password and hash algorithm. - Pass the
WriteProtectionOptionsobject to the Presentation.protect() method.
The following code snippet applies password-based write protection:
package presentation;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import java.io.*;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
try(Presentation presentation =
new Presentation(
Files.readAllBytes(
Path.of("Presentation.pptx")))) {
// Enable write protection.
WriteProtectionOptions options =
new WriteProtectionOptions("password", HashAlgorithmType.SHA512);
presentation.protect(options);
Path outputDir = Path.of("output");
Files.createDirectories(outputDir);
// Save the protected presentation.
try (FileOutputStream fileStream = new FileOutputStream(
outputDir.resolve("ProtectedPresentation.pptx").toFile())) {
presentation.saveDocument(fileStream);
}
}
}
}
Refer to the following help topic for additional information: Protect a Presentation from Editing.
Inherited Members
com.devexpress.system.JavaObject.clone()
com.devexpress.system.JavaObject.equals(java.lang.Object)
com.devexpress.system.JavaObject.hashCode()
com.devexpress.system.JavaObject.initFields()
com.devexpress.system.JavaObject.memberwiseClone()
com.devexpress.system.JavaObject.toString()
java.lang.Object.finalize()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)
Inheritance
Object
com.devexpress.system.JavaObject
WriteProtectionOptions
Constructors
WriteProtectionOptions(String password, HashAlgorithmType hashAlgorithm) Constructor
Initializes a new instance of the WriteProtectionOptions class with the specified password and hash algorithm.
Declaration
public WriteProtectionOptions(String password, HashAlgorithmType hashAlgorithm)
Parameters
| Name | Type | Description |
|---|---|---|
| password | String | A password for write protection. |
| hashAlgorithm | HashAlgorithmType | A hash algorithm for password protection. |
WriteProtectionOptions(String password) Constructor
Initializes a new instance of the WriteProtectionOptions class with the specified password.
Declaration
public WriteProtectionOptions(String password)
Parameters
| Name | Type | Description |
|---|---|---|
| password | String | A password for write protection. |
Methods
getHashAlgorithm() Method
Returns the hash algorithm used to protect the presentation.
Declaration
public HashAlgorithmType getHashAlgorithm()
Returns
| Type | Description |
|---|---|
| HashAlgorithmType | The hash algorithm. |
getPassword() Method
Returns the password used to protect the presentation from editing.
Declaration
public String getPassword()
Returns
| Type | Description |
|---|---|
| String | The password. |