0

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

JDx
  • 2,615
  • 3
  • 22
  • 33

2 Answers2

4

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.

Perception
  • 79,279
  • 19
  • 185
  • 195
0

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

JDx
  • 2,615
  • 3
  • 22
  • 33