Dealing with Large Encrypted Files

If you implement custom encryption, you should provide an object implementing the PSPDFDataProviding protocol and initialize the PSPDFDocument using initWithDataProviders:.

PSPDFKit already implements the PSPDFAESCryptoDataProvider. It uses PSPDFDataProviding and provides all the delegates to dynamically decrypt just the required part of the PDF on the fly. You just provide the unencrypted file size and the callbacks for direct access.

The naive approach to this would be using NSData with PSPDFDataContainerProvider, but this is limited to the amount of available memory, and generally not a good idea once your documents are above 20 MB.

Careful: You should disable the disk cache by setting its allowedDiskSpace to 0 otherwise it will pretty much invalidate the benefit of encrypting the PDF.