Disabling Adding Pages With Images

Q: In the Document Editor, how can I disable letting the user add new pages from their Photo Library or the Camera?

A: You can remove the item outlined in red in the screenshot above by filtering out the page template with the image identifier from the pageTemplates of the documentEditorConfiguration of the main PSPDFKit configuration.

Copy
1
2
3
4
5
6
7
let pdfViewController = PDFViewController(document: document) { mainConfigBuilder in
    mainConfigBuilder.documentEditorConfiguration = mainConfigBuilder.documentEditorConfiguration.configurationUpdated { docEditorConfigBuilder in
        docEditorConfigBuilder.pageTemplates = docEditorConfigBuilder.pageTemplates.filter { pageTemplate -> Bool in
            pageTemplate.identifier != .image
        }
    }
}