DocumentAccessMode Enum
Lists values that specify the access level for a PDF document.
Declaration
public enum DocumentAccessMode extends Enum<DocumentAccessMode> implements IIntEnum
Members
| Name | Description |
|---|---|
OWNER
|
The document is encrypted and can only be opened with the owner’s password. |
UNENCRYPTED
|
The document is unencrypted and can be opened without a password. |
USER
|
The document is encrypted and can only be opened with the user’s password. |
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 PdfDocument.getAccessMode() method to obtain the document access mode.
The following code snippet opens an encrypted PDF document, verifies the current access mode, and inspects document permissions:
try (InputStream documentStream =
Files.newInputStream(Path.of("Document.pdf"));
PdfDocument pdfDocument =
new PdfDocument(documentStream, "YOUR_PASSWORD")) {
// Display the current access mode and document permissions.
System.out.println(
"Access mode: " + pdfDocument.getAccessMode() +
"\nData extraction permissions: " + pdfDocument.getDataExtractionPermissions() +
"\nModification permissions: " + pdfDocument.getModificationPermissions() +
"\nInteractivity permissions: " + pdfDocument.getInteractivityPermissions());
}
Refer to the following help topic for additional information: Encrypt PDF Documents.