iPhone - pdf encryption

血红的双手。 提交于 2019-12-22 01:18:41

问题


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 approach this. Any help is much appreciated.

Thanks


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/6763942/iphone-pdf-encryption

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!