# Search and Replace

DsPdf is a Document Solutions product that offers a rich library to read, create, modify, and save PDF files without using any external tool.

## Content

DsPdfViewer allows you to perform the Search and Replace operation using **Replace text** options in **Floating Search Bar**. By default, the Search icon is available in the toolbar, which, when clicked, opens the Floating Search Bar. You can also open the Floating Search Bar by pressing **Ctrl+F**. Furthermore, DsPdfViewer also allows you to open Replace text options directly by pressing **Ctrl+H**.
![](https://cdn.mescius.io/document-site-files/images/884d2bfb-301b-49bc-8d90-656c5b910507/images/search-and-replace.png)
You can perform the Search operation using several advanced search options, such as match case, wildcard, proximity, and more. Once the Search operation is complete, you can replace the highlighted words found individually with **Replace current** (![](https://cdn.mescius.io/document-site-files/images/884d2bfb-301b-49bc-8d90-656c5b910507/images/replace-next.png)) option or choose the **Replace all** (![](https://cdn.mescius.io/document-site-files/images/884d2bfb-301b-49bc-8d90-656c5b910507/images/replace-all.png)) option to replace all instances of the searched text at once. Refer to the following GIF image that showcases the Search and Replace operation:
![](https://cdn.mescius.io/document-site-files/images/884d2bfb-301b-49bc-8d90-656c5b910507/images/search-and-replace-operation.gif)

> !type=note
> **Note:** For more information on Search operation, see [Search](/document-solutions/dot-net-pdf-api/docs/online/pdfviewer/view-pdf/viewerfeatures/advanced-search-options).

> !type=note
> **Note:** Replace text options are enabled only when the viewer is configured with SupportApi. Hence, the feature is available only with a Professional License. For more information, see [Configure Server-Based PDF Editor](/document-solutions/dot-net-pdf-api/docs/online/pdfviewer/edit-pdf/configure-pdf-editor).

## Toggle Search Bar Programmatically

DsPdfViewer also enables you to display Search and Replace text options programmatically using **toggleSearchUI** method. This method accepts **expand** and **replaceMode** as parameters. The expand parameter sets whether to expand or collapse Floating Search Bar. Whereas, the replaceMode sets whether to enable Replace text options in the Floating Search Bar.
Refer to the following example code to expand Floating Search Bar and enable Replace text options:

```javascript
// Expand Floating Search Bar and enable Replace Text.
viewer.open("realestate-lease.pdf").then(
    res => {
        viewer.toggleSearchUI(true, true);
    }
);
```

Refer to the following example code to collapse Floating Search Bar:

```javascript
// Collapse Floating Search Bar.
viewer.open("realestate-lease.pdf").then(
    res => {
        viewer.toggleSearchUI(false);
    }
);
```