Function

CGPDFDocumentUnlockWithPassword

Unlocks an encrypted PDF document when a valid password is supplied.

Declaration

bool CGPDFDocumentUnlockWithPassword(CGPDFDocumentRef document, const char *password);

Parameters

document

A PDF document.

password

A pointer to a string that contains the password.

Return Value

A Boolean that, if YES, indicates that the document has been successfully unlocked. If the value is NO, the document has not been unlocked.

Discussion

Given an encrypted PDF document and a password, this function does the following:

  • Sets the lock state of the document, based on the validity of the password.

  • Returns YES if the document is unlocked.

  • Returns NO if the document cannot be unlocked with the specified password.

Unlocking a PDF document makes it possible to decrypt the document and perform other privileged operations. Different passwords enable different operations.

See Also

Managing Encryption

CGPDFDocumentAllowsCopying

Returns whether the specified PDF document allows copying.

CGPDFDocumentAllowsPrinting

Returns whether a PDF document allows printing.

CGPDFDocumentIsEncrypted

Returns whether the specified PDF file is encrypted.

CGPDFDocumentIsUnlocked

Returns whether the specified PDF document is currently unlocked.