> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/basic-operations/basics/find-text-i.md).

# Add text search bar to Xamarin PDF viewer

Learn how to implement text search functionality in Xamarin.iOS using the PTTextSearchViewController class. Highlight search results, navigate through documents, and customize search options. Add the

{% hint style="info" %}
**This tutorial only applies to Xamarin.iOS. See Xamarin.Android equivalent here .**
{% endhint %}

The [`PTTextSearchViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTextSearchViewController.html) class allows the user to enter and search text in a document. Search results are automatically highlighted in the document and a toolbar with navigation buttons allows searching forward or backward through the document. The core text search functionality is provided by the `PTPDFViewCtrl`'s text search methods.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-5b996e58859c24b85e6b62bc67642b88c7b6715f%2F751784ed5090a448a7c6c10669313b4ca6f4f856-1242x2208.png?alt=media)

*The search view controller is part of the Tools library, so make sure you have* [*added the Tools library to your project*](/xamarin/ui-customization/setup.md)*.*

## Showing a text search view controller

To create and set up a text search view controller, supply a `PTPDFViewCtrl` instance to the `PTTextSearchViewController` designated initializer:

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
var textSearchViewController = new PTTextSearchViewController(mPdfViewCtrl);
textSearchViewController.SearchViewControllerDidDismiss += (sender, e) =>
{
    
};
var navigationController = new UINavigationController(textSearchViewController);

if (UserInterfaceIdiomIsPhone)
{
    navigationController.ModalPresentationStyle = UIModalPresentationStyle.Custom;
}
else
{
    navigationController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
    navigationController.PopoverPresentationController.BarButtonItem = searchButton;
}

this.PresentViewController(navigationController, true, null);
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
**The search view controller does not create its own top navigation bar, so it must be pushed onto a navigation controller's stack.**
{% endhint %}

## Search results list view

The [`PTTextSearchViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTextSearchViewController.html) also presents the search results in a [`UITableView`](https://developer.apple.com/uikit/uitableview/) for fast and easy navigation. Selecting any result in the table view will immediately navigate to that result and highlight it.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-0f6e4cec66513b1e061b53385da57beb32df4d8b%2F08cf4fd3cf391932800026c39ccb26afb382d8d2-1242x2208.png?alt=media)

## Search options

The [`PTTextSearchViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTextSearchViewController.html) interface also allows the user to refine the search to be case-sensitive, or to match whole words only:

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-78bd27828d88921be427867d6e894bdf06e92ec3%2Fa495a97d93efa8972f0dce4876598b822261e148-1242x2208.png?alt=media)

## The text search view controller delegate

The [`PTTextSearchViewControllerDelegate`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTTextSearchViewControllerDelegate.html) protocol allows the adopting class (usually the containing view controller, as in this guide) to be notified when the view controller has been dismissed. This can be used to show or hide other content as appropriate.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/basic-operations/basics/find-text-i.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
