Options to disable or enable PDF editing on iOS
Control PDF editing to meet security requirements, protect document integrity, or create appropriate user experiences. Common use cases include distributing read-only contracts, enforcing compliance requirements, and managing workflow-specific editing permissions.
There are several ways to modify PDF documents — for instance, by adding annotations or filling forms. The PDF format has standard restrictions (refer to the secured documents guide), but in addition to those built-in restrictions, Nutrient gives you control over how to restrict certain modifications of PDF documents.
Annotations
The following section assumes you’re familiar with annotations. If not, refer to the annotations overview guide.
Disabling the modification of all annotation types
You can disable all annotation modifications using PDFConfiguration by setting the editableAnnotationTypes property to nil. This will prevent users from adding new annotations and editing existing ones:
let configuration = PDFConfiguration { $0.editableAnnotationTypes = nil}PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) { builder.editableAnnotationTypes = nil;}];Enabling modifications only for specific annotation types
You can control which annotation types are editable, and you can specify their types in editableAnnotationTypes. For example, you can enable only the modification of ink annotations:
let configuration = PDFConfiguration { $0.editableAnnotationTypes = [.ink]}PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) { builder.editableAnnotationTypes = [NSSet setWithArray:@[PSPDFAnnotationStringInk]]; // Only ink annotations are editable.}];Disabling adding new annotations but enabling modification of existing ones
Hiding your PDFViewController’s annotationButtonItem from the toolbar will prevent users from adding new annotations, but it won’t stop them from editing or deleting existing ones:
// Notice that `pdfController.annotationButtonItem` isn't included.pdfController.navigationItem.setRightBarButtonItems([pdfController.thumbnailsButtonItem, pdfController.outlineButtonItem, pdfController.searchButtonItem, pdfController.activityButtonItem], for: .document, animated: false)// Notice that `pdfController.annotationButtonItem` isn't included.[pdfController.navigationItem setRightBarButtonItems:@[pdfController.thumbnailsButtonItem, pdfController.outlineButtonItem, pdfController.searchButtonItem, pdfController.activityButtonItem] forViewMode:PSPDFViewModeDocument animated:NO];For more information, refer to the guide on configuring editable/visible annotation types.
Disabling the modification of a specific annotation
You can disable the modification of a specific annotation by updating its flags property to use Annotation.Flag.readOnly. For example:
// Update the annotation flags.annotation.flags.update(with: .readOnly)// Update the annotation flags.annotation.flags |= ~PSPDFAnnotationFlagReadOnly;For more information, refer to the guide on annotation flags.
Disabling adding annotations using menus
You can add annotations using the menu that shows up when you long press on empty space. This menu contains the Paste action and tools for creating different annotations. To disable this menu entirely, set the isCreateAnnotationMenuEnabled configuration property to false:
let configuration = PDFConfiguration { $0.isCreateAnnotationMenuEnabled = false}Text markup annotations can also be created by selecting text. For example, when you select text in a document, you can highlight it. To exclude the highlight tool from the text selection menu, use the contentMenuConfiguration property:
let configuration = PDFConfiguration { $0.contentMenuConfiguration = ContentMenuConfiguration { $0.annotationToolChoices = { _, _, _, defaultChoices in defaultChoices.filter { $0 != .highlight } } }}To learn more about different menus and how to customize them, refer to our guide on customizing menus.
Disabling drag and drop
PDFs can be modified using drag and drop. For example, you can drag and drop text, images, and even other PDF documents to create annotations within a document. You can disable drag and drop by configuring your DragAndDropConfiguration:
let dragAndDropConfiguration = DragAndDropConfiguration { $0.acceptedDropTypes = [] $0.allowedDropTargets = []}let configuration = PDFConfiguration { $0.dragAndDropConfiguration = dragAndDropConfiguration}PSPDFDragAndDropConfiguration *dragAndDropConfiguration = [PSPDFDragAndDropConfiguration configurationWithBuilder:^(PSPDFDragAndDropConfigurationBuilder * builder) { builder.acceptedDropTypes = PSPDFDropTypeNone; builder.allowedDropTargets = PSPDFDropTargetNone;}];PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) { builder.dragAndDropConfiguration = dragAndDropConfiguration;}];For more information, refer to the guide on drag and drop.
Forms
The following section assumes you’re familiar with forms. If not, refer to the what are forms? guide.
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 has the DocumentPermissions.annotationsAndForms or DocumentPermissions.fillForms permissions disabled, the SDK prevents form filling automatically. Alternatively, you can set editableAnnotationTypes to exclude .widget to achieve the same restriction at the application level, regardless of document permissions.
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 enable all other form elements to be editable:
let document = Document(url: documentURL)
// Disable only text field form elements.for formElement: FormElement in (document.formParser?.forms)! where formElement is TextFieldFormElement { formElement.isEditable = false}PSPDFDocument *document = [[PSPDFDocument alloc] initWithURL:documentURL];
// Disable only text field form elements.for (PSPDFFormElement *formElement in document.formParser.forms) { if ([formElement isKindOfClass:PSPDFTextFieldFormElement.class]) { formElement.editable = NO; }}For a complete list of supported form element types and their corresponding classes, refer to the form fields guide.
Choosing the right restriction approach
When deciding how to restrict form interactions, consider the following scenarios:
- Disable all forms — Use when distributing final documents where no modifications should occur, such as published reports or archived contracts.
- Disable specific form types — Use when you need selective editing capabilities, such as allowing signatures while preventing text field changes during approval workflows.
- Lock individual fields — Use for workflow stages where some fields are finalized while others remain editable, such as locking approved sections of a multi-stage form.
Restricting document editing features
PDF documents can be modified using the Document Editor feature, which enables new page creation, page duplication, and the reordering, rotation, or deletion of pages. Refer to the document editing guide for implementation steps.