This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/ios/knowledge-base/how-do-i-get-notified-when-a-password-protected-document-is-unlocked.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Get notified when a PDF is unlocked

If you initialize a PDFViewController with a password-protected document, the documentViewController property is nil until the document is unlocked.

You can implement PDFViewControllerDelegate.pdfViewController(_:didChange:error:) to get the non-nil document view controller when the document is unlocked, like so:

let pdfController = PDFViewController(document: lockedDocument)
pdfController.delegate = self
...
func pdfViewController(_ pdfController: PSPDFViewController, didChange controllerState: PSPDFControllerState, error: Error?) {
if controllerState == .default {
if let layout = pdfController.documentViewController?.layout as? ContinuousScrollingLayout {
layout.fillAlongsideTransverseAxis = true
}
}
}