Document Solutions for PDF
Document Solutions PDF Viewer Overview / Edit PDF / Search and Replace
In This Topic
    Search and Replace
    In This Topic

    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:

    Note: For more information on Search operation, see Search.
    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.

    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
    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);
        }
    );