DocumentModificationPermissions Enum
Lists values that specify permission levels for document modification operations.
Declaration
public enum DocumentModificationPermissions extends Enum<DocumentModificationPermissions> implements IIntEnum
Members
| Name | Description |
|---|---|
ALLOWED
|
Allows document modification and assembly operations. |
DOCUMENT_ASSEMBLING
|
Allows document assembly operations only, including inserting, rotating, or deleting pages and creating bookmarks in the navigation pane. |
NOT_ALLOWED
|
Prohibits document modification and assembly operations. |
fromValue(int value)
|
Returns the enum item with the specified integer value. |
getName()
|
Returns the enum item name. |
getValue()
|
Returns the integer value. |
toString()
|
Returns the string representation. |
valueOf(String name)
|
Returns the enum constant with the specified name. |
values()
|
Returns available constants. |
Remarks
Use the EncryptionOptions.setModificationPermissions() method to define document modification permissions.
The following code snippet loads a PDF document, encrypts it, restricts specific operations, and saves the result:
import com.devexpress.docs.pdf.*;
import java.nio.file.*;
import java.nio.channels.*;
public class Main {
public static void main(String[] args) throws Exception {
try (FileChannel channel = FileChannel.open(Path.of("Document.pdf"));
PdfDocument pdfDocument = new PdfDocument(channel)) {
EncryptionOptions encryptionOptions = new EncryptionOptions(
"ownerPassword",
"userPassword"
) {{
setDataExtractionPermissions(DocumentDataExtractionPermissions.NOT_ALLOWED);
setPrintPermissions(DocumentPrintPermissions.LOW_QUALITY);
setModificationPermissions(DocumentModificationPermissions.NOT_ALLOWED);
setAlgorithm(EncryptionAlgorithm.AES_256);
}};
pdfDocument.encrypt(encryptionOptions);
// Save the encrypted document.
try (WritableByteChannel writableByteChannel =
FileChannel.open(Path.of("Document_encrypted.pdf"),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {
pdfDocument.save(writableByteChannel);
}
}
}
}
Refer to the following help topic for additional information: Encrypt PDF Documents.