> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/web/documentviewer/interacting-with-tools.md).

# Interacting with tools with the Document Viewer

Enhance your document viewing experience with the ability to interact with various tools within the Document Viewer. Discover how tools in the Core.Tools namespace enable you to create annotations, se

[DocumentViewer](https://sdk.apryse.com/api/web/Core.DocumentViewer.html) comes with ability to change and use tools within the viewer element. Tools are used to create/interact with annotations, select text, and perform other actions. They are found in the [`Core.Tools`](https://sdk.apryse.com/api/web/Core.Tools.html) namespace. Not only are tools used in the default WebViewer setup, they can also be used in your [custom viewer](/web/ui-customization/core.md).

## Getting tools

Although you can instantiate a tool manually, this is typically not necessary as the DocumentViewer comes with some default, initialized tools. You can get one of the tools using the `getTool` API and the name that the tool was registered with.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const editTool = documentViewer.getTool('AnnotationEdit');
```

{% endcode %}
{% endtab %}
{% endtabs %}

[DocumentViewer.getTool](https://sdk.apryse.com/api/web/Core.DocumentViewer.html#getTool)

There is an enumeration, [`Core.Tools.ToolNames`](https://sdk.apryse.com/api/web/Core.Tools.html#.ToolNames), that makes this accessing the tools easier.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const editTool = documentViewer.getTool(Core.Tools.ToolNames.EDIT);
```

{% endcode %}
{% endtab %}
{% endtabs %}

[ToolNames](https://sdk.apryse.com/api/web/Core.Tools.html#.ToolNames)

When there is an active tool, you can fetch it directly using the `getToolMode` API.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
const currentTool = documentViewer.getToolMode();
```

{% endcode %}
{% endtab %}
{% endtabs %}

[DocumentViewer.getToolMode](https://sdk.apryse.com/api/web/Core.DocumentViewer.html#getToolMode)

## Changing tools

You can call the `setToolMode` API to change tools from the DocumentViewer.

{% tabs %}
{% tab title="JavaScript" %}
{% code lineNumbers="true" %}

```js
documentViewer.addEventListener('documentLoaded', () => {
    // Changes to the edit tool on every document load
    documentViewer.setToolMode(documentViewer.getTool(Core.Tools.ToolNames.EDIT));
});
```

{% endcode %}
{% endtab %}
{% endtabs %}

[DocumentViewer.setToolMode](https://sdk.apryse.com/api/web/Core.DocumentViewer.html#setToolMode)

## Next steps

Learn more about [annotations](/web/annotation/annotation.md) and the [tools](/web/annotation/annotations-and-tools.md) that create them!


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/web/documentviewer/interacting-with-tools.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
