Rendering PDF Forms in Our iOS Viewer

The following section assumes you’re familiar with forms. If not, first see the introduction to forms guide for more details.

Form Support in PSPDFKit

PSPDFKit supports all form types specified by the PDF specification. We have to differentiate between field objects and annotation objects.

Type Field Object Annotation Object
Check, Radio, and Push Buttons ButtonFormField ButtonFormElement
List and Combo Boxes ChoiceFormField ChoiceFormElement
Text TextFormField TextFieldFormElement
Signatures SignatureFormField SignatureFormElement

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;
	}
}

Licensing

PDF Forms is a separate component in your PSPDFKit license. Without this feature included in your license, your app won’t be able to view or interact with PDF forms. Please contact our sales team to add this feature to your license, or use a trial license if you want to try out this feature.

Signature form fields and signature form elements require that your license includes either Electronic Signatures or Digital Signatures, or that your license was originally obtained in April 2021 or earlier. If none of these requirements are met, then signature elements will be omitted, and other form elements will be shown.