---
title: "Open password-protected PDF on iOS | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/open-a-document/password-protected-pdfs/"
md_url: "https://www.nutrient.io/guides/ios/open-a-document/password-protected-pdfs.md"
last_updated: "2026-06-08T19:21:59.232Z"
description: "Unlock and open password-protected PDFs on iOS using Nutrient iOS SDK. Learn to integrate documents and display them with custom settings effectively."
---

# Open password-protected PDFs on iOS

Nutrient iOS SDK enables you to open password-protected PDFs. This article shows how to open a password-protected PDF document both using the user interface and programmatically.

First, you need to add the password-protected PDF document you want to display to your application by dragging it into your project. On the dialog that’s displayed, select Finish to accept the default integration options. You can use [this password-protected PDF file](/downloads/protected.pdf) as an example.

Then, load your PDF document and display the view controller. This can be done in a button action handler, table view cell selection delegate, or similar:

```swift

// Update to use your document name and location.
let fileURL = Bundle.main.url(forResource: "Document", withExtension: "pdf")!
let document = Document(url: fileURL)

// The configuration closure is optional and allows additional customization.
let pdfController = PDFViewController(document: document) {
	$0.isPageLabelEnabled = false
}

// Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.
present(UINavigationController(rootViewController: pdfController), animated: true)

```

When you open the password-protected PDF, Nutrient will prompt you to enter the password. You can use “test123” as the password to unlock the document:

For more details about opening a password-protected document programmatically, refer to [`PasswordNotPresetExample.swift`] in the [Nutrient Catalog](https://github.com/PSPDFKit/pspdfkit-ios-catalog) app.

## Opening a password-protected PDF programmatically

Nutrient also allows you to programmatically unlock password-protected PDFs by presetting the password before loading the document, allowing you to bypass the password prompt for your end users:

```swift

// Update to use your document name.
let fileURL = Bundle.main.url(forResource: "Document", withExtension: "pdf")!
let document = Document(url: fileURL)

// Unlock the document before displaying it.
// Note: In a real application, you should protect the password better than hardcoding it here.
document.unlock(withPassword: "test123")

// The configuration closure is optional and allows additional customization.
let pdfController = PDFViewController(document: document) {
	$0.isPageLabelEnabled = false
}

// Present the PDF view controller within a `UINavigationController` to show built-in toolbar buttons.
present(UINavigationController(rootViewController: pdfController), animated: true)

```

For more details about opening a password-protected document programmatically, refer to [`PasswordPresetExample.swift`] in the [Nutrient Catalog](https://github.com/PSPDFKit/pspdfkit-ios-catalog) app.
---

## Related pages

- [File coordination on iOS](/guides/ios/features/file-coordination.md)
- [Open a PDF from a custom data provider on iOS](/guides/ios/features/data-providers.md)
- [Open a PDF from in-memory data on iOS](/guides/ios/open-a-document/from-in-memory-data.md)
- [Open a PDF from Document Engine on iOS](/guides/ios/open-a-document/from-document-engine.md)
- [Open a local file on iOS](/guides/ios/open-a-document/from-local-storage.md)
- [Document Downloads](/guides/ios/miscellaneous/document-downloads.md)
- [Open a PDF on iOS](/guides/ios/open-a-document.md)
- [Troubleshoot opening a document](/guides/ios/open-a-document/troubleshooting.md)

