安全pdf:锁定/不可编辑,以防止在iOS设备生成后的更改

时间:2022-03-25 21:11:23

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.

我正在使用UIKit框架在iOS设备中生成pdf。我想知道我们是否可以对生成的pdf进行锁定(提供安全性),以便在发送或下载后,不能使用任何pdf可编辑工具进行编辑/修改。

1 个解决方案

#1


4  

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:

是的——这是可能的。如果您开始创建一个带有UIGraphicsBeginPDFContextToFile的PDF,那么您就可以向它发送一个字典以指定您想要的加密/锁定类型。以下是它的文件:

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

http://developer.apple.com/library/ios/文档/ uikit /引用/ UIKitFunctionReference /引用/ 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  );

#1


4  

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:

是的——这是可能的。如果您开始创建一个带有UIGraphicsBeginPDFContextToFile的PDF,那么您就可以向它发送一个字典以指定您想要的加密/锁定类型。以下是它的文件:

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

http://developer.apple.com/library/ios/文档/ uikit /引用/ UIKitFunctionReference /引用/ 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  );