PdfFileSecurity

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

NameTypeAccessDescription
inputFileStringReadReturns the configured input file path.
outputFileStringReadReturns the configured output file path.
documentDocumentReadReturns the bound Document, or {@code null}.
outputStreamOutputStreamReadReturns the configured output stream.
allowExceptionsbooleanReadReturns whether facade methods should throw immediately when an operation fails.
encryptedbooleanReadReturns whether the bound document is encrypted.

Methods

SignatureDescription
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()StringReturns the configured input file path.
setInputFile(inputFile: String)Sets the configured input file path.
getOutputFile()StringReturns the configured output file path.
setOutputFile(outputFile: String)Sets the configured output file path.
setInputStream(inputStream: InputStream)Sets the configured input stream.
getDocument()DocumentReturns the bound Document, or {@code null}.
getOutputStream()OutputStreamReturns the configured output stream.
setOutputStream(outputStream: OutputStream)Sets the configured output stream.
isAllowExceptions()booleanReturns whether facade methods should throw immediately when an operation fails.
setAllowExceptions(allowExceptions: boolean)Sets the exception behavior flag.
bindPdf(inputFile: String)booleanBinds a PDF file to this security facade.
bindPdf(inputStream: InputStream)booleanBinds a PDF from an input stream.
bindPdf(document: Document)booleanBinds an existing {@link Document} to this security facade.
save(outputFile: String)booleanSaves the bound document to a file.
save(outputStream: OutputStream)booleanSaves the bound document to an output stream.
save()booleanSaves the bound document to the configured output destination.
decryptFile(password: String)booleanDecrypts the bound PDF document.
isEncrypted()booleanReturns whether the bound document is encrypted.
setPrivilege(userPassword: String, ownerPassword: String, permissions: int)booleanSets document privileges using explicit password strings and a raw bitmask.
setPrivilege(privilege: DocumentPrivilege)booleanSets document privileges using empty passwords.
setPrivilege(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege)booleanSets document privileges and applies standard encryption using the supplied
passwords.
encryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize)booleanEncrypts the document using the specified key size.
encryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm)booleanEncrypts the document using the specified key size and algorithm family.
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String)booleanChanges the document passwords while preserving the current permissions and
algorithm.
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize)booleanChanges passwords and privilege flags using the specified key size.
changePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm)booleanChanges passwords, privilege flags, and algorithm family.
trySetPrivilege(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege)booleanAttempts to set privileges and returns {@code false} instead of throwing.
tryEncryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize)booleanAttempts to encrypt and returns {@code false} instead of throwing.
tryEncryptFile(userPassword: String, ownerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm)booleanAttempts to encrypt and returns {@code false} instead of throwing.
tryDecryptFile(password: String)booleanAttempts to decrypt and returns {@code false} instead of throwing.
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String)booleanAttempts to change password and returns {@code false} instead of throwing.
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize)booleanAttempts to change password and returns {@code false} instead of throwing.
tryChangePassword(oldPassword: String, newPassword: String, newOwnerPassword: String, privilege: DocumentPrivilege, keySize: KeySize, algorithm: Algorithm)booleanAttempts to change password and returns {@code false} instead of throwing.
close()Closes the security facade and releases the bound document.

See Also