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

筅森魡賤 提交于 2020-01-01 07:01:28

问题


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.


回答1:


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  );


来源:https://stackoverflow.com/questions/10286732/secure-pdf-locked-uneditable-to-prevent-changes-after-generating-from-ios-devi

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