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

风流意气都作罢 提交于 2019-12-03 20:18:01

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