Document Solutions for PDF
Document Solutions PDF Viewer Overview / View PDF / Features / Search
In This Topic
    Search
    In This Topic

    DsPdfViewer lets you perform the Search operation using several advanced search options, such as match case, wild card, proximity, and more. By default, the Search icon is available in the toolbar, which, when clicked, opens the floating search bar. However, you can even place the Search panel in the sidebar by disabling the Floating search bar, as described ahead.

    Floating Search Bar

    DsPdfViewer provides a floating text search bar at the top-right corner, just below the toolbar. You can open the floating text search bar using the toolbar icon () or by pressing Ctrl+F. Then, you can initiate the search by typing in the desired search term in the designated search input field. As you start typing, the search mechanism automatically begins searching for matches within the document, highlighting or displaying results in real-time as you type. This dynamic search process allows immediate feedback and helps a user quickly locate the relevant content.

    Note: When you press Ctrl+F again, DsPdfViewer will focus on the search input again if it is not already focused.

    The floating text search bar provides various advanced search options in the Settings () button to customize and fine-tune your search preferences. It eliminates irrelevant options and narrows down the scope of a search query.

    You can close the floating text search bar using the Close () button or by pressing the ESC key when the search input is focused.

    Sidebar Search Panel

    You can also use the sidebar search panel by setting ‘useFloatingSearchBar’ option to false. The sidebar search panel also provides advanced search options, along with displaying the count of total search results and the page number on which the specific result is found.

    Refer to the following example code to use the sidebar search panel:

    C#
    Copy Code
    // Use sidebar search panel instead of floating search bar.
    var viewer = new DsPdfViewer("#root", { useFloatingSearchBar: false });
    

    Advanced search options in GcDocs PDF Viewer

    Advance Search Options

    The following sections explain the various advanced search options provided in DsPdfViewer:

    Match Case

    This option finds all those instances in a PDF document that are written in the same case (lower or upper) as specified in the search query.

    Example: If you search "test", the search results displays "test", "tests", "testing" but not "Test".

    Whole Word

    The 'Whole Word' option finds all those occurrences in a PDF document which contain the whole word as specified in the search query.

    Example: If you search "demo", the search results displays "demo", "Demo" but not "demonstration", "demos".

    Starts With

    This option finds all the occurences in a PDF document which starts with the characters specified in the search query.

    Example: If you search "us", the search results display "us", "used", "Users" but not "various", "status".

    Ends With

    This option finds all the occurences in a PDF document which ends with the characters specified in the search query.

    Example: If you search "at", the search results display "at", "format", "treat" but not "attribute", "atom".

    Wildcards

    The 'Wildcard' option can be used to maximize the search results. You can type a part of a word and use any number of wildcard characters with it. DsPdfViewer supports two wildcard characters:

    Note: Wildcard search option cannot be combined with 'Starts With', 'Ends With' and 'Whole Word' options.

    Proximity

    The 'Proximity' option can be used to search for two or more words that are separated by a certain number of words from each other. The operator AROUND(n) can be used to specify the maximum count of words between search terms. The search results includes only those words which are present on the same page of a PDF document.

    Example: Consider the below text in a PDF document:

    Several species of game fish live or spawn in wetlands. Hundreds, if not thousands, of invertebrates that form the food of birds also rely on water for most, if not all, phases of their existence. In fact, most all species of animals we have must spend at least part of the year in wetlands. To lose any more of these vital areas is almost unthinkable.

    Case 1:

    Search Query: species AROUND(8) wetlands

    Result: species of game fish live or spawn in wetlands

    Explanation: The words “species” and “wetlands” are present at a gap of 7 words from each other. In order to display this search result, the value of 'n' should be 7 or greater.


    Case 2:

    Search Query: species wetlands

    Results: species of game fish live or spawn in wetlands 

                 species of animals we have must spend at least part of the year in wetlands

    Explanation: If operator AROUND(n) is not specified, the search results will include all words from query without any location constraint.


    Case 3:

    Search Query: species AROUND(8) wetlands AROUND(4) thousands

    Result: species of game fish live or spawn in wetlands. Hundreds, if not thousands

    Explanation: The words “species”, “wetlands” and "thousands" are present at the specified gaps.

    Note: Proximity search option cannot be combined with 'Starts With', 'Ends With' and 'Wildcard' options.        

    Highlight all

    The search results are highlighted all at once when 'Highlight all' option is checked in the search panel. The below code example shows how to change the default highlight colors by using the 'useCanvasForSelection' option:

    Index.cshtml
    Copy Code
    var viewer = new DsPdfViewer('#root',
        {
            useCanvasForSelection:
            {
                selectionColor: 'rgba(0, 0, 195, 0.25)',
                highlightColor: 'rgba(255, 0, 0, 0.35)',
                inactiveHighlightColor: "rgba(180, 0, 170, 0.35)"
            }
        });