---
title: "Generate a password-protected PDF on iOS | Nutrient"
canonical_url: "https://www.nutrient.io/guides/ios/pdf-generation/password-protected-pdf/"
md_url: "https://www.nutrient.io/guides/ios/pdf-generation/password-protected-pdf.md"
last_updated: "2026-05-15T19:10:05.028Z"
description: "Learn to create a password-protected PDF on iOS using Nutrient iOS SDK. Implement security options and secure your documents with custom passwords effectively."
---

# Generate a password-protected PDF on iOS

Nutrient iOS SDK allows you to generate a password-protected document. To accomplish this task, you’ll need to use the `securityOptions` exposed by [`Processor`](https://www.nutrient.io/api/ios/documentation/pspdfkit/processor)’s initializer.

> See [`CreatePasswordProtectedDocumentExample`](https://github.com/PSPDFKit/pspdfkit-ios-catalog/blob/master/Catalog/Examples/Security/CreatePasswordProtectedDocumentExample.swift) from the Catalog app for a complete example of how to create a password-protected document.

```swift

// Create a `configuration` as described in any of the other PDF generation guides.
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: configuration, securityOptions: documentSecurityOptions)
    try processor.write(toFileURL: outputFileURL)
} catch {
    // Handle error.
}

// Initialize the password-protected document.
let passwordProtectedDocument = Document(url: outputFileURL)

```
---

## Related pages

- [Generate PDFs from HTML on iOS](/guides/ios/pdf-generation/from-html.md)
- [Generate blank PDFs on iOS](/guides/ios/features/document-creation.md)
- [Generate PDFs from templates on iOS](/guides/ios/miscellaneous/custom-page-templates.md)
- [Generate PDF reports on iOS](/guides/ios/generating-pdfs/generating-pdf-reports.md)
- [Generate PDFs from a PDF form in iOS](/guides/ios/pdf-generation/from-pdf-form.md)
- [PDF generation library for iOS](/guides/ios/pdf-generation.md)
- [Generate PDFs from images on iOS](/guides/ios/pdf-generation/from-images.md)
- [Generate PDF thumbnails on iOS](/guides/ios/pdf-generation/thumbnail-preview.md)
- [Generate PDFs programmatically on iOS](/guides/ios/pdf-generation/programmatically.md)

