Disable PDF Form Editing in iOS

The PDF format has standard restrictions (see the Secured Documents guide). In addition to those built-in restrictions, PSPDFKit gives you control over how to restrict modifications to forms.

Disabling All Form Interactions

You can disable all form interactions and modifications using editableAnnotationTypes:

let configuration = PDFConfiguration {
	var editableAnnotationTypes = $0.editableAnnotationTypes
	editableAnnotationTypes?.remove(.widget)
	$0.editableAnnotationTypes = editableAnnotationTypes
}
PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
	NSMutableSet *editableAnnotationTypes = [builder.editableAnnotationTypes mutableCopy];
	[editableAnnotationTypes removeObject:PSPDFAnnotationStringWidget];
	builder.editableAnnotationTypes = editableAnnotationTypes;
}];

If a document doesn’t have the DocumentPermissions.annotationsAndForms and DocumentPermissions.fillForms document permissions, the result will be the same for the user, meaning they won’t be able to fill any form fields.

Disabling Specific Form Element Types

You can specify which form elements can be modified. For example, you can disable the modification of all text field form elements and allow all other form elements to be editable:

let document = Document(url: documentURL)

// Loop through all form elements from a given document and only disable text field form elements from being modified.
for formElement: FormElement in (document.formParser?.forms)! where formElement is TextFieldFormElement {
	formElement.isEditable = false;
}
PSPDFDocument *document = [[PSPDFDocument alloc] initWithURL:documentURL];

// Loop through all form elements from a given document and only disable text field form elements from being modified.
for (PSPDFFormElement *formElement in document.formParser.forms) {
	if ([formElement isKindOfClass:PSPDFTextFieldFormElement.class]) {
		formElement.editable = NO;
	}
}