iphone - 安全 pdf : locked/uneditable to prevent changes after generating from iOS device

标签 iphone objective-c xcode security pdf-generation

我正在使用 UIKit 框架在 iOS 设备中生成 pdf。 我想知道我们是否可以锁定(提供安全性)生成的 pdf,以便在通过电子邮件发送或下载它之后,人们无法使用任何 pdf 可编辑工具进行编辑/修改。

最佳答案

是的——这是可能的。如果您使用 UIGraphicsBeginPDFContextToFile 开始创建 PDF,您可以向其发送一个字典,其中包含指定您想要的加密/锁定类型的选项。这是它的文档:

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

这是一个创建它的例子:

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

关于iphone - 安全 pdf : locked/uneditable to prevent changes after generating from iOS device,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10286732/

相关文章:

ios - 仅当高于特定 iOS 版本时如何有条件地包含代码?

ios - Objective-C if 语句中的求值 (NSIntegers)

ios - 如何使用 AutoLayout 使我的 UIImage 的高度与我的 UILabel 的固有高度相同?

iOS : UIScrollView scrolling reset controls position to initials

iOS - 键盘建议气泡错误地隐藏在键盘后面

ios - 使用 Objective-C 的 HTTP 客户端上传图像

php - 使用 Xcode 6 和 PHP 文件将图像上传到服务器

ios - UIPopoverPresentationController 无法设置箭头颜色

iphone - iOS:旋转 iPhone 后,直接从仅支持纵向模式的 View Controller 以横向方式呈现 View Controller

iphone - 要在 plist 中指定的图标文件