Customizing PDF Editing Permissions in iOS

This guide covers editing of document permissions. To get an initial overview of what PDF document permissions are and how they’re incorporated into PSPDFKit, please first take a look at the Permissions guide.

Modifying a document’s permissions requires PSPDFKit to be instantiated with a license that includes the Document Editor component.

It’s worth noting that if you wish to modify the default document permissions with PSPDFKit, you’ll be required to protect the document with a password.

You can retrieve the current permissions of a document via the Document.permissions property. This property is read-only and will only return the permissions out of the first file when the document is comprised of multiple underlying files.

Document permissions can be set using the Document.SecurityOptions class when interacting with the document processor. After you define your desired security options, you instantiate a Processor object with it:

do {
  let documentSecurityOptions = try Document.SecurityOptions(ownerPassword: password, userPassword: password, keyLength: Document.SecurityOptionsKeyLengthAutomatic, permissions: [.annotationsAndForms])
} catch {
  // Handle error.
guard let processorConfiguration = Processor.Configuration(document: document) else {

// Create a processor and write the file with the permissions applied.
let processor = Processor(configuration: processorConfiguration, securityOptions: securityOptions)
try processor.write(toFileURL: outputFileURL)
PSPDFDocumentSecurityOptions *securityOptions = [[PSPDFDocumentSecurityOptions alloc] initWithOwnerPassword:password userPassword:password keyLength:PSPDFDocumentSecurityOptionsKeyLengthAutomatic permissions:PSPDFDocumentPermissionsAnnotationsAndForms error:&error];
PSPDFProcessorConfiguration *processorConfiguration = [[PSPDFProcessorConfiguration alloc] initWithDocument:document];

// Create a processor and write the file with the permissions applied.
PSPDFProcessor *processor = [[PSPDFProcessor alloc] initWithConfiguration:processorConfiguration securityOptions:securityOptions];
[processor writeToFileURL:outputFileURL error:&error];

Users can also customize the permissions directly from the UI via PDFDocumentSecurityViewController.