Secure pdf: locked / uneditable to prevent changes after creating from an iOS device

I am using the UIKit Framework to generate pdf on an iOS device. I am wondering if we can block (ensure security) the generated PDF file so that after sending it by e-mail or downloading it cannot be edited or modified using any editable PDF tool.

+3
source share
1 answer

Yes it is possible. If you start creating a PDF using UIGraphicsBeginPDFContextToFile, you can send it a dictionary with options to indicate what type of encryption / blocking you want. Here is the documentation for it:

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

All Articles