user1140780
user1140780

Reputation: 988

secure pdf : locked/uneditable to prevent changes after generating from iOS device

I am using UIKit Framework to generate pdf in iOS device. I am wondering if we can lock (provide security) to the generated pdf so that after emailing or downloading it , one can not edit/modify using any pdf editable tool.

Upvotes: 3

Views: 783

Answers (1)

Mazen
Mazen

Reputation: 41

Yes - this is possible. If you start the creation of a PDF with UIGraphicsBeginPDFContextToFile you can then send a dictionary to it with options to specify what kind of encryption/locking you want. Here is the documentation for it:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIKitFunctionReference/Reference/reference.html

And here is an example creating it:

NSDictionary * pdfInfo = nil;

if (trimmedPassPhrase && [trimmedPassPhrase length] > 0) {
    pdfInfo = [NSDictionary dictionaryWithObjectsAndKeys:trimmedPassPhrase, kCGPDFContextOwnerPassword,
               trimmedPassPhrase, kCGPDFContextUserPassword,
               [NSNumber numberWithInt:128], kCGPDFContextEncryptionKeyLength, nil];
}


BOOL pdfContextSuccess =  UIGraphicsBeginPDFContextToFile(newFilePath, CGRectZero, pdfInfo  );

Upvotes: 4

Related Questions