开发者

iPhone - pdf encryption

I've been searching the internet for most of the day today trying to find an answer to this problem. Bascially, I'm trying to create a small app which receives pdfs (from the iTunes file explorer and from a url) then encrypts them and saves them for decryption later.

I've tried using Quartz but with not a lot of documentation available, its difficult. I'm just looking for some guidance on how i should a开发者_高级运维pproach this. Any help is much appreciated.

Thanks


You can use the PDFDocument class in Quartz2D to read PDF data from a file or a URL. Once read, you can then save the document with optional encryption via the property kCGPDFContextOwnerPassword.

Reading:

PDFDocument * pdfDoc = [[PDFDocument alloc] initWithData: data];
//or
PDFDocument * pdfDoc = [[PDFDocument alloc] initWithURL: url];

Writing, encrypted:

NSDictionary * pdfOpts = [NSDictionary dictionaryWithObjectsAndKeys: kCGPDFContextOwnerPassword, @"mypassword", nil];
[pdfDoc writeToFile: somepath withOptions: pdfOpts];

You can get a complete list of the specifiable options from the CGPDFContext Reference on Apple's developer web site.


I figured it out. Im using this: http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜