Reputation: 988
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
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:
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