---
title: "iOS Library to Search Text in PDF | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/features/text-search/"
md_url: "https://www.nutrient.io/guides/ios/features/text-search.md"
last_updated: "2026-05-18T06:34:32.281Z"
description: "Master text searching in PDFs using Nutrient iOS SDK. Learn to implement customizable UI components and enhance user experience with efficient document searches."
---

# Search for Text in PDFs on iOS

PSPDFKit offers many different ways to search a document, including using a highly customizable UI component. PSPDFKit also offers a component that enables efficient search across a set of documents. To learn more about that, check out the [Indexed Full-Text Search](https://www.nutrient.io/guides/ios/features/indexed-full-text-search.md) guide.

## Searching Using the User Interface

In most cases, you’ll want to trigger a search inside [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller). This can be done by calling [`search(for:options:sender:animated:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/search(for:options:sender:animated:)). PSPDFKit will automatically anchor the popover to the search button or show a modal dialog for compact size classes like the iPhone. Options can take one parameter, [`.searchHeadless`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/presentationoption/searchheadless), which invokes a search but doesn’t trigger any UI. This is great for unobtrusive highlighting:

### SWIFT

```swift

let searchString = "Example Search Text"
pdfController.search(for: searchString, options: [.searchHeadless: true], sender: nil, animated: true)

```

### OBJECTIVE-C

```objc

NSString *searchString = @"Example Search Text";
[pdfController searchForString:searchString options:@{PSPDFPresentationOptionSearchHeadless: @YES} sender:nil animated:YES];

```

When a search result is selected, [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller) navigates to the page of the result and zooms in to the text. PSPDFKit allows you to modify the scale of the zoom performed using the [`searchResultZoomScale`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration/searchresultzoomscale) property on the [`PDFConfiguration`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfconfiguration) object. It defaults to [`PSPDFAutomaticSearchResultZoomScale`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pspdfautomaticsearchresultzoomscale), which enables automatic zoom scaling of the selected search result.

This automatic zoom can be disabled:

### SWIFT

```swift

let controller = PDFController(document: document) {
    // Set `searchResultZoomScale` to `1` to disable zooming altogether.
    $0.searchResultZoomScale = 1.0
}

```

### OBJECTIVE-C

```objc

PSPDFConfiguration *configuration = [PSPDFConfiguration configurationWithBuilder:^(PSPDFConfigurationBuilder *builder) {
    // Set `searchResultZoomScale` to `1` to disable zooming altogether.
    builder.searchResultZoomScale = 1.0;
}];
PSPDFViewController *controller = [[PSPDFViewController alloc] initWithDocument:document configuration:configuration];

```

## Searching Programmatically

To search text inside a document, create an instance of [`TextSearch`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch), passing in the loaded [`Document`](https://www.nutrient.io/api/ios/documentation/pspdfkit/document) via its initializer. Searching can be triggered via calling [`search(for:)`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/search(for:)), which will start a search on a background queue. Implement [`TextSearchDelegate`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearchdelegate) on the receiving object and set the text search object’s `delegate` to your object to be notified of search result updates.

You need to retain the text search object while the search is running. Otherwise, any running search will automatically be canceled and your delegate won’t get called.

## Specifying the Search Options

Before triggering a search, you can configure various search options:

- [`comparisonOptions`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/comparisonoptions-swift.property) — Use this for regular expression (regex) search and to control case and diacritic insensitivity.

- [`previewRange`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/previewrange)

- [`searchableAnnotationTypes`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/searchableannotationtypes)

- [`maximumNumberOfSearchResults`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/maximumnumberofsearchresults)

Changing these properties once a search operation is running isn’t supported and might result in unexpected behavior.

To learn more about searching annotations and the [`searchableAnnotationTypes`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textsearch/searchableannotationtypes) option, see the [Annotation Search](https://www.nutrient.io/guides/ios/search/search-in-a-pdf/annotation-search.md) guide.

## Highlighting Search Results

Search results, represented by [`SearchResult`](https://www.nutrient.io/api/ios/documentation/pspdfkit/searchresult), offer the content (selection) as a [`TextBlock`](https://www.nutrient.io/api/ios/documentation/pspdfkit/textblock) and a [`previewText`](https://www.nutrient.io/api/ios/documentation/pspdfkit/searchresult/previewtext). You can use these objects to represent your own search result list or to manually highlight parts of a page.

[`SearchHighlightViewManager`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightviewmanager) manages the task of showing and hiding search results. It can be accessed via the [`searchHighlightViewManager`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller/searchhighlightviewmanager) property on [`PDFViewController`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfviewcontroller), and it offers a way to both add ([`addHighlight(_:animated)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightviewmanager/addhighlight(_:animated:))) and clear ([`clearHighlightedSearchResults(animated:)`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightviewmanager/clearhighlightedsearchresults(animated:))) search results.

[`SearchHighlightView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightview) will be added on top of a visible [`PDFPageView`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/pdfpageview) for each search result. It can be customized via `UIAppearance` — see [`selectionBackgroundColor`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightview/selectionbackgroundcolor) and [`cornerRadiusProportion`](https://www.nutrient.io/api/ios/documentation/pspdfkitui/searchhighlightview/cornerradiusproportion).
---

## Related pages

- [Search PDF Annotations on iOS](/guides/ios/search/search-in-a-pdf/annotation-search.md)

