views:

176

answers:

1

Hi all

I have a PDF document that has an owner password set but no user password. Therefore it is encrypted.

I know the owner password and want to use PDFKit to confirm when the document has been decrypted.

I have used the PDFDocument unlockWithPassword method which returns YES when the file is unlocked. However this method also returns yes when the file has been unlocked by a user password and not the owner password.

The unlockWithPassword method appears not to change the state of the isEncrpyted method which I tried to use to confirm the decryption.

I want to decrpyt the file so that I can use the write methods to write a new file with no security. At the moment calling this method on the document object results in a zero length file being created. I assume this is because of the encryption.

Am I going about this the right way or should I be using a different method for decrypting the pdf file.

Thanks in advance.

Craig Wanstall

A: 

Once you unlock the PDF, you will need to write it back to a file using:

writeToFile:withOptions:

or

writeToURL:withOptions:

Options being an NSDictionary. According to Apple: "The most commonly-used options are kCGPDFContextOwnerPassword, kCGPDFContextUserPassword, kCGPDFContextAllowsCopying and kCGPDFContextAllowsPrinting."

"For more details about these options, see the “Auxiliary Dictionary Keys” in CGPDFContext Reference, part of the Quartz 2D Reference."

K_T