Some test text!

Search
Hamburger Icon

Web / Guides / Interacting with tools

Interacting with tools with the Document Viewer

DocumentViewer 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 namespace. Not only are tools used in the default WebViewer setup, they can also be used in your custom viewer .

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.

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

There is an enumeration, Core.Tools.ToolNames, that makes this accessing the tools easier.

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

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

const currentTool = documentViewer.getToolMode();

Changing tools

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

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

Next steps

Learn more about annotations and the tools that create them!

Get the answers you need: Chat with us