---
title: "Drag and drop text or images in iOS PDF viewer | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/features/drag-and-drop/"
md_url: "https://www.nutrient.io/guides/ios/features/drag-and-drop.md"
last_updated: "2026-05-29T15:33:59.482Z"
description: "Users can drag and drop various elements from and to an application that integrates Nutrient iOS SDK."
---

# Drag and drop text or images in our iOS viewer

Users can drag and drop various elements from and to an application that integrates Nutrient.

## Drag interactions

There are various elements users can initiate a drag from. The following interactions are currently possible with Nutrient:

- Dragging images embedded on a document page

- Dragging text from a document page

## Drop interactions

Additionally, users can drop elements on a document page, and these elements are then converted into PDF annotations. Annotations can be created, updated, and deleted if your license includes the Annotations component.

Here’s the list of drop interactions that are currently supported:

- Dropping text on a document page. The text will be converted into a free text annotation.

- Dropping an image on a document page. The image will be converted into an image stamp annotation.

- Dropping a PDF on a document page. The PDF will be converted into an image stamp annotation of the first page of the dropped document.

## Customizing drag and drop

All drag-and-drop interactions are enabled by default. However, you can selectively control specific drag-and-drop components using [`DragAndDropConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration). This might be interesting for you if you provide an application that serves documents with sensitive data.

[`DragAndDropConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration) can be constructed the same way as the main [`PDFConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration) class. To customize a drag-and-drop configuration, you can set a [`DragAndDropConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration) object to the [`dragAndDropConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/draganddropconfiguration) property of [`PDFConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration), like so:

### SWIFT

```swift

let pdfController = PDFViewController(document: document) {
    let dragAndDropConfiguration = PSPDFDragAndDropConfiguration { dragAndDropConfigurationBuilder in
        // Customize the drag-and-drop configuration.
    }
    $0.dragAndDropConfiguration = dragAndDropConfiguration
}

```

### OBJECTIVE-C

```objc

PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    PSPDFDragAndDropConfiguration *dragAndDropConfiguration = [PSPDFDragAndDropConfiguration configurationWithBuilder:^(PSPDFDragAndDropConfigurationBuilder *dragAndDropConfigurationBuilder) {
        // Customize the drag-and-drop configuration.
    }];
    builder.dragAndDropConfiguration = dragAndDropConfiguration;
}];
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document configuration:configuration];

```

### Control drag elements

The configuration of elements that users can initiate a drag from can be controlled via [`allowedDragTypes`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration/alloweddragtypes). By default, all types are allowed.

If you only want to allow dragging text from a document, you can configure this as follows:

### SWIFT

```swift

dragAndDropConfigurationBuilder.allowedDragTypes =.text

```

### OBJECTIVE-C

```objc

dragAndDropConfigurationBuilder.allowedDragTypes = PSPDFDragTypeText;

```

### Control drag targets

Drags that were initiated from a source application can be dropped either into the same application or into another application.

To restrict dragging inside the source application, you can disable [`allowDraggingToExternalApps`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration/allowdraggingtoexternalapps).

### Control drop elements

Configuring elements that users can drop onto a document page can be controlled via [`acceptedDropTypes`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration/accepteddroptypes). By default, all types are accepted.

If you only want to accept dropping images and PDFs onto a document, you can configure this as follows:

### SWIFT

```swift

dragAndDropConfigurationBuilder.acceptedDropTypes = [.image,.PDF]

```

### OBJECTIVE-C

```objc

dragAndDropConfigurationBuilder.acceptedDropTypes = PSPDFDropTypeImage | PSPDFDropTypePDF;

```

### Control drop targets

Drop elements can be dropped on document pages, which can be customized via [`allowedDropTargets`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration/alloweddroptargets). By default, this is allowed for drags from any other page in the document, apart from the current one, and for drags from an external application.

To allow drops from all targets, including the document page where the drag was initiated from, use the following code:

### SWIFT

```swift

dragAndDropConfigurationBuilder.allowedDropTargets =.all

```

### OBJECTIVE-C

```objc

dragAndDropConfigurationBuilder.allowedDropTargets = PSPDFDropTargetAll;

```

## Custom interactions

In case the built-in drag-and-drop support doesn’t meet your requirements, you can also handle drag-and-drop interactions yourself. Reasons for this might be to validate the interactions or to create custom annotations for a drop.

In such a case, you can use your own drag-and-drop interactions instead of using our default ones. This can be done by adding your custom interactions to a [`PDFPageView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfpageview) subclass and handling the drag or drop there. Additionally, you might want to disable our default interactions, so as to not cause conflicts with your custom interactions via [`DragAndDropConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/draganddropconfiguration).

To add a custom interaction for handling drops, you can use the following logic:

### SWIFT

```swift

class PageView: PDFPageView {
    override init(frame: CGRect) {
        super.init(frame: frame)

        let dropInteraction = UIDropInteraction(delegate: self)
        self.addInteraction(dropInteraction)
    }
}

extension PageView: UIDropInteractionDelegate {

    func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool {
        return true
    }

    func dropInteraction(_ interaction: UIDropInteraction, sessionDidUpdate session: UIDropSession) -> UIDropProposal {
        return UIDropProposal(operation:.copy)
    }

    func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
        // Handle drop.
    }
}

let controller = PDFViewController(document: document) {
    let dragAndDropConfiguration = DragAndDropConfiguration { dragAndDropBuilder in
        dragAndDropBuilder.allowDraggingToExternalApps = false
        dragAndDropBuilder.acceptedDropTypes = []
        dragAndDropBuilder.allowedDragTypes = []
        dragAndDropBuilder.allowedDropTargets = []
    }
    $0.dragAndDropConfiguration = dragAndDropConfiguration

    $0.overrideClass(PDFPageView.self, with: PageView.self)
}

```

### OBJECTIVE-C

```objc

@interface PSCPageView : PSPDFPageView <UIDropInteractionDelegate> @end
@implementation PSCPageView

- (instancetype)initWithFrame:(CGRect)frame {
    if ((self = [super initWithFrame:frame])) {
        UIDropInteraction *dropInteraction = [[UIDropInteraction alloc] initWithDelegate:self];
        [self addInteraction:dropInteraction];
    }
    return self;
}

- (BOOL)dropInteraction:(UIDropInteraction *)interaction canHandleSession:(id<UIDropSession>)session {
    return YES;
}

- (UIDropProposal *)dropInteraction:(UIDropInteraction *)interaction sessionDidUpdate:(id<UIDropSession>)session {
    return [[UIDropProposal alloc] initWithDropOperation:UIDropOperationCopy];
}

- (void)dropInteraction:(UIDropInteraction *)interaction performDrop:(id<UIDropSession>)session {
    // Handle drop.
}

@end

PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    PSPDFDragAndDropConfiguration *dragAndDropConfiguration = [PSPDFDragAndDropConfiguration configurationWithBuilder:^(PSPDFDragAndDropConfigurationBuilder *dragAndDropBuilder) {
        dragAndDropBuilder.allowDraggingToExternalApps = NO;
        dragAndDropBuilder.acceptedDropTypes = PSPDFDropTypeNone;
        dragAndDropBuilder.allowedDragTypes = PSPDFDragTypeNone;
        dragAndDropBuilder.allowedDropTargets = PSPDFDropTargetNone;
    }];
    builder.dragAndDropConfiguration = dragAndDropConfiguration;

    [builder overrideClass:PSPDFPageView.class withClass:PSCPageView.class];
}];
PSPDFViewController *controller = [[PSPDFViewController alloc] initWithDocument:document configuration:configuration];

```
---

## Related pages

- [Selecting text in our iOS viewer](/guides/ios/features/text-selection.md)
- [Trackpad and mouse support in our iOS viewer](/guides/ios/features/trackpad-and-mouse-support.md)
- [Keyboard shortcuts in our iOS viewer](/guides/ios/features/keyboard-shortcuts.md)
- [Customize user interactions on iOS](/guides/ios/customizing-the-interface/handling-user-interactions.md)
- [Customize zooming options in our iOS viewer](/guides/ios/miscellaneous/zooming.md)

