PdfFileSecurity
Overview
PdfFileSecurity is a class in Aspose.Pdf FOSS for Java.
Inherits from: Closeable.
Provides methods for managing PDF document security: encryption, decryption, passwords, and access permissions.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
inputFile | String | Read | Returns the configured input file path. |
outputFile | String | Read | Returns the configured output file path. |
document | Document | Read | Returns the bound Document, or {@code null}. |
outputStream | OutputStream | Read | Returns the configured output stream. |
allowExceptions | boolean | Read | Returns whether facade methods should throw immediately when an operation fails. |
encrypted | boolean | Read | Returns whether the bound document is encrypted. |
Methods
| Signature | Description |
|---|---|
PdfFileSecurity() | Creates a new {@code PdfFileSecurity} instance. |
PdfFileSecurity(inputFile: String, outputFile: String) | Creates a facade bound to the specified input and output files. |
PdfFileSecurity(inputStream: InputStream, outputStream: OutputStream) | Creates a facade bound to the specified input and output streams. |
PdfFileSecurity(document: Document, outputStream: OutputStream) | Creates a facade bound to the specified document and output stream. |
getInputFile() → String | Returns the configured input file path. |
setInputFile(inputFile: String) | Sets the configured input file path. |
getOutputFile() → String | Returns the configured output file path. |
setOutputFile(outputFile: String) | Sets the configured output file path. |
setInputStream(inputStream: InputStream) | Sets the configured input stream. |
getDocument() → Document | Returns the bound Document, or {@code null}. |
getOutputStream() → OutputStream | Returns the configured output stream. |
setOutputStream(outputStream: OutputStream) | Sets the configured output stream. |
isAllowExceptions() → boolean | Returns whether facade methods should throw immediately when an operation fails. |
setAllowExceptions(allowExceptions: boolean) | Sets the exception behavior flag. |
bindPdf(inputFile: String) → boolean | Binds a PDF file to this security facade. |
bindPdf(inputStream: InputStream) → boolean | Binds a PDF from an input stream. |
bindPdf(document: Document) → boolean | Binds an existing {@link Document} to this security facade. |
save(outputFile: String) → boolean | Saves the bound document to a file. |
save(outputStream: OutputStream) → boolean | Saves the bound document to an output stream. |
save() → boolean | Saves the bound document to the configured output destination. |
decryptFile(password: String) → boolean | Decrypts the bound PDF document. |
isEncrypted() → boolean | Returns whether the bound document is encrypted. |
setPrivilege(userPassword: String, ownerPassword: String, permissions: int) → boolean | Sets document privileges using explicit password strings and a raw bitmask. |
setPrivilege(privilege: DocumentPrivilege) → boolean | Sets document privileges using empty passwords. |
setPrivilege(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege) → boolean | Sets document privileges and applies standard encryption using the supplied |
| passwords. | |
encryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize) → boolean | Encrypts the document using the specified key size. |
encryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm) → boolean | Encrypts the document using the specified key size and algorithm family. |
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String) → boolean | Changes the document passwords while preserving the current permissions and |
| algorithm. | |
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize) → boolean | Changes passwords and privilege flags using the specified key size. |
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm) → boolean | Changes passwords, privilege flags, and algorithm family. |
trySetPrivilege(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege) → boolean | Attempts to set privileges and returns {@code false} instead of throwing. |
tryEncryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize) → boolean | Attempts to encrypt and returns {@code false} instead of throwing. |
tryEncryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm) → boolean | Attempts to encrypt and returns {@code false} instead of throwing. |
tryDecryptFile(password: String) → boolean | Attempts to decrypt and returns {@code false} instead of throwing. |
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String) → boolean | Attempts to change password and returns {@code false} instead of throwing. |
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize) → boolean | Attempts to change password and returns {@code false} instead of throwing. |
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm) → boolean | Attempts to change password and returns {@code false} instead of throwing. |
close() | Closes the security facade and releases the bound document. |