开发者

Cocoa PDFKit Unlocking Encrypted Files

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 开发者_Python百科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.


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."

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜