# Toolbar and Tools

Internally, the PDFViewer uses the [Telerik UI for ASP.NET Core Toolbar](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/toolbar/overview) and provides a set of default tools and corresponding commands in its toolbar.

You can also define [custom tools](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/pdf/pdfviewer/toolbar#custom-tools) in the toolbar that trigger custom logic.

## Built-In Tools

You can control the number and type of the rendered tools by adding only the desired tools in the [`Items()`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/pdfviewertoolbarsettingsbuilder#itemssystemaction) configuration of the `Toolbar`. For the full list of configuration options, refer to the [client-side API of the ToolBar items](https://docs.telerik.com/kendo-ui/api/ui/pdfviewer/configuration/toolbar.items).

The toolbar of the PDFViewer supports the following built-in tools:

* `pager`
* `zoom`
* `zoomInOut`
* `toggleSelection`
* `search`
* `open`
* `download`
* `print`
* `annotations`

> Running an Adblock extension in Chrome might treat the new browser tab for the print dialog as a potential ad and block it.

The `zoom`, `zoomInOut`, `toggleSelection`, `search`, and `print` tools are available only with [PDFjs processing](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/pdf/pdfviewer/pdfjs-processing).

The following example demonstrates basic configuration options for the PDFViewer toolbar tools. You can also add `spacer` elements to group a specific set of tools.

```Razor HtmlHelper
    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .Toolbar(toolbar =>
            toolbar.Items(items =>
            {
                items.Add().Name("pager");
                items.Add().Name("spacer");
                items.Add().Name("zoom");
                items.Add().Name("zoomInOut");
                items.Add().Name("toggleSelection");
                items.Add().Name("search");
                items.Add().Name("open");
                items.Add().Name("download");
                items.Add().Name("print");
            })
        )
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-pdfviewer name="pdfviewer">
        <toolbar enabled="true">
            <pdfviewer-toolbar-items>
                <pdfviewer-toolbar-item name="pager">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="spacer">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="zoom">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="zoomInOut">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="toggleSelection">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="search">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="open">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="download">
                </pdfviewer-toolbar-item>
                <pdfviewer-toolbar-item name="print">
                </pdfviewer-toolbar-item>
            </pdfviewer-toolbar-items>
        </toolbar>
    </kendo-pdfviewer>
```

The `open`, `download`, and `print` built-in tools are displayed on the right-side of the toolbar (next to the `search` tool) by default. To update the default appearance of these tools and display them as options of a [DropDownList](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/editors/dropdownlist/overview), which is added as first item in the toolbar, enable the [`ContextMenu`](https://www.telerik.com/aspnet-core-ui/documentation/api/kendo.mvc.ui.fluent/pdfviewertoolbarsettingsbuilder#contextmenu) option of the `Toolbar` configuration.

```Razor HtmlHelper
    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .Toolbar(toolbar => toolbar.ContextMenu(true))
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

    <kendo-pdfviewer name="pdfviewer">
        <toolbar enabled="true" context-menu="true">
        </toolbar>
    </kendo-pdfviewer>
```

You can also use the [`add()`](https://docs.telerik.com/kendo-ui/api/ui/toolbar/methods/add) and [`remove()`](https://docs.telerik.com/kendo-ui/api/ui/toolbar/methods/remove) client-side API methods to programmatically manage the rendered tools in the PDFViewer.

```Razor HtmlHelper
    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")     
    )
```

```Razor TagHelper
    <kendo-pdfviewer name="pdfviewer">
    </kendo-pdfviewer>
```

```JS
    <script>    
      var pdfviewer = $("#pdfviewer").getKendoPDFViewer(); // Get a reference to the PDFViewer.
      var printToolElement = $(".k-toolbar").find('button[data-command="PrintCommand"]'); // Select the 'print' tool button with jQuery.
      pdfviewer.toolbar.remove(printToolElement); // Remove the 'print' tool.
      pdfviewer.toolbar.add({ // Add a custom tool in the toolbar.
        type: "button",
        text: "Custom tool", 
        click: function() { 
            console.log("Cuatom tool button is clicked.");
        },
        togglable: true
      });
    </script>
```

### Overflow Behavior

The built-in toolbar provides properties for customizing its overflow behavior and appearance.
The following example demonstrates how to modify the default overflow settings of the toolbar through the `Oveflow()` configuration.

```Razor
    @(Html.Kendo().PDFViewer().Name("pdfviewer")
        .PdfjsProcessing(pdf => pdf.File(Url.Content("~/shared/web/pdfViewer/sample.pdf")))
        .Height(700)
        .Toolbar(t => t
            .Overflow(o => o
              .Mode(ToolBarOverflowMode.Scroll)
              .ScrollButtons(ScrollButtonsType.Auto)
              .ScrollButtonsPosition(ScrollButtonsPositionType.Start)
              .ScrollDistance(50)
            )
        )
    )
```

```Razor TagHelper
    <kendo-pdfviewer name="pdfviewer"
                     height="700">
        <pdfjs-processing file="@Url.Content("~/shared/web/pdfViewer/sample.pdf")" />
        <toolbar>
            <overflow mode="ToolBarOverflowMode.Scroll" scroll-buttons="ScrollButtonsType.Auto" scroll-buttons-position="ScrollButtonsPositionType.Start" scroll-distance="50" />
        </toolbar>
    </kendo-pdfviewer>
```

For more information on the available overflow options, refer to the [Appearance documentation of the ToolBar component](https://www.telerik.com/aspnet-core-ui/documentation/html-helpers/navigation/toolbar/appearance).

## Custom Tools

The toolbar of the PDFViewer component supports custom tools.

The following example demonstrates how to add a custom tool to the toolbar.

```Razor HtmlHelper
    @(Html.Kendo().PDFViewer()
        .Name("pdfviewer")
        .Toolbar(toolbar =>
            toolbar.Items(items =>
            {
                items.Add().Text("Custom tool").Click("customToolClick").Type("button");
            })  
        )
    )
```

```Razor TagHelper
    @addTagHelper *, Kendo.Mvc

     <kendo-pdfviewer name="pdfviewer">
        <toolbar enabled="true">
            <pdfviewer-toolbar-items>
                <pdfviewer-toolbar-item text="Custom tool" click="customToolClick" type="button">
                </pdfviewer-toolbar-item>
            </pdfviewer-toolbar-items>
        </toolbar>
    </kendo-pdfviewer>
```

```JS
    <script>
        function customToolClick() {
            // Execute the desired custom logic when the custom tool is clicked.
        }
    </script>
```

## See Also

* [Basic Usage of the PDFViewer HtmlHelper for ASP.NET Core (Demo)](https://demos.telerik.com/aspnet-core/pdfviewer/index)

* [Client-Side API Reference of the ToolBar for ASP.NET Core](https://docs.telerik.com/kendo-ui/api/ui/toolbar)

* [Server-Side API Reference of the PDFViewer for ASP.NET Core](https://www.telerik.com/aspnet-core-ui/documentation/api/pdfviewer)

* [Server-Side TagHelper API Reference of the PDFViewer for ASP.NET Core](https://www.telerik.com/aspnet-core-ui/documentation/api/taghelpers/pdfviewer)
