Get notifications for unlocked password-protected PDFs
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 } } }
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:lockedDocument]; pdfController.delegate = self; ... - (void)pdfViewController:(PSPDFViewController *)pdfController didChangeControllerState:(PSPDFControllerState)controllerState error:(nullable NSError *)error { if (controllerState == PSPDFControllerStateDefault) { PSPDFDocumentViewLayout *layout = pdfController.documentViewController.layout; if ([layout isKindOfClass:PSPDFContinuousScrollingLayout.class]) { ((PSPDFContinuousScrollingLayout *)layout).fillAlongsideTransverseAxis = YES; } } }