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.
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 () option or choose the Replace all () option to replace all instances of the searched text at once. Refer to the following GIF image that showcases the Search and Replace operation:
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 |
Copy Code
|
---|---|
// 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 |
Copy Code
|
---|---|
// Collapse Floating Search Bar. viewer.open("realestate-lease.pdf").then( res => { viewer.toggleSearchUI(false); } ); |