Creating password-protected PDFs on iOS

Nutrient’s Processor API can generate a password-protected document from another document. You can use Processor to create a new password-protected PDF document on disk based on a current Document. See CreatePasswordProtectedDocumentExample from the Catalog app for a complete example of how to create a password-protected document:

// By default, a newly initialized `Processor.Configuration` results in an exported document that is the same as the input.
guard let processorConfiguration = Processor.Configuration(document: originalDocument) else { return }
do {
// Set the proper password and key length in `Document.SecurityOptions`.
let documentSecurityOptions = try Document.SecurityOptions(ownerPassword: ownerPassword, userPassword: userPassword, keyLength: Document.SecurityOptionsKeyLengthAutomatic)
let processor = Processor(configuration: processorConfiguration, securityOptions: documentSecurityOptions)
try processor.write(toFileURL: outputFileURL)
} catch {
// Handle error.
}
// Initialize the password-protected document.
let passwordProtectedDocument = Document(url: outputFileURL)