---
title: "Create password-protected PDF on iOS | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/document-security/add-a-password/"
md_url: "https://www.nutrient.io/guides/ios/document-security/add-a-password.md"
last_updated: "2026-05-19T18:11:33.947Z"
description: "Learn to create a password-protected PDF on iOS using Nutrient’s Processor API. Secure your documents with custom owner and user passwords efficiently."
---

# Creating password-protected PDFs on iOS

Nutrient’s [`Processor`](https://www.nutrient.io/api/ios/documentation/pspdfkit/processor) API can generate a password-protected document from another document. You can use [`Processor`](https://www.nutrient.io/api/ios/documentation/pspdfkit/processor) to create a new password-protected PDF document on disk based on a current [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document). See `CreatePasswordProtectedDocumentExample` from the Catalog app for a complete example of how to create a password-protected document:

### SWIFT

```swift

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

```

### OBJECTIVE-C

```objc

// By default, a newly initialized `PSPDFProcessorConfiguration` results in an exported document that is the same as the input.
PSPDFProcessorConfiguration *processorConfiguration = [[PSPDFProcessorConfiguration alloc] initWithDocument:originalDocument];

// Set the proper password and key length in `PSPDFDocumentSecurityOptions`.
PSPDFDocumentSecurityOptions *documentSecurityOptions = [[PSPDFDocumentSecurityOptions alloc] initWithOwnerPassword:ownerPassword userPassword:userPassword keyLength:PSPDFDocumentSecurityOptionsKeyLengthAutomatic error:&error];

PSPDFProcessor *processor = [[PSPDFProcessor alloc] initWithConfiguration:processorConfiguration securityOptions:documentSecurityOptions];
[processor writeToFileURL:outputFileURL error:NULL];

// Initialize the password-protected document.
PSPDFDocument *passwordProtectedDocument = [[PSPDFDocument alloc] initWithURL:outputFileURL];
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:passwordProtectedDocument];

```
---

## Related pages

- [Securing PDFs by adding watermarks on iOS](/guides/ios/document-security/add-a-watermark.md)
- [Document security on iOS](/guides/ios/document-security.md)
- [Encrypt PDFs with AES on iOS](/guides/ios/security/encrypt-or-decrypt-files-on-the-server.md)
- [Introduction to PDF encryption on iOS](/guides/ios/security/introduction-to-encryption.md)
- [Prevent sharing of PDF files on iOS](/guides/ios/document-security/prevent-sharing.md)
- [Decrypt PDFs with AES on iOS](/guides/ios/security/aesdataprovider.md)
- [Managing PDF restrictions on iOS](/guides/ios/document-security/set-permissions.md)

