---
title: "Extract selected text from PDF on iOS | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/extraction/selected-text/"
md_url: "https://www.nutrient.io/guides/ios/extraction/selected-text.md"
last_updated: "2026-05-21T11:22:21.609Z"
description: "Discover how to implement text selection in Nutrient's iOS UI, including gestures, contextual menus, and custom operations with API hooks."
---

# Extract selected text from PDFs on iOS

Nutrient’s document viewing UI has built-in support for text selection, which was designed to exactly match the text selection behavior in stock iOS components. The text selection UI includes full support standard touch and cursor-based text selection gestures, a built-in contextual menu, and support for multi-finger system gestures for text operations such as copying.

In addition to the bundled UI behaviors, it’s also possible to build additional operations on the selected text by leveraging the provided API hooks. This guide covers two convenient options.

## Selection callback

[`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller) can inform your code of text selection changes via a dedicated delegate callback. To use it, assign [`PDFViewController.delegate`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/delegate) to your object and implement the [`pdfViewController(_,didSelectText:,with:,at:,on:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontrollerdelegate/pdfviewcontroller(_:didselecttext:with:at:on:)) callback:

```swift

pdfController.delegate = self

// MARK: `PDFViewControllerDelegate`

func pdfViewController(_ pdfController: PDFViewController, didSelectText text: String, with glyphs: [Glyph], at rect: CGRect, on pageView: PDFPageView) {
    // Do something with the selected text.
    print(text)
}

```

## Text selection view

Each visible PDF page of a document in a [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller) will be represented by a [`PageView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfpageview) instance in the view hierarchy. Those objects in turn reference a [`TextSelectionView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/textselectionview) instance, which exposes various operations related to text selection.

To get an array of all the selected text blocks on the visible pages, you can use the following code snippet:

```swift

let selectedText = pdfController.visiblePageViews.compactMap { pageView in
    return pageView.selectionView.selectedText
}

```
---

## Related pages

- [PDF extraction library for iOS](/guides/ios/extraction.md)
- [Extract metadata from PDFs on iOS](/guides/ios/extraction/metadata.md)
- [Extract images from PDFs on iOS](/guides/ios/extraction/image-extraction.md)
- [Extract pages from PDFs on iOS](/guides/ios/extraction/page-extraction.md)
- [Parse PDF content on iOS](/guides/ios/extraction/parse-content.md)
- [Extract text from PDFs on iOS](/guides/ios/features/text-extraction.md)
- [Extract the text position from PDFs on iOS](/guides/ios/extraction/text-position.md)

