PDFViewer.activateTool()
Activate a tool (again: put it away, back to the resting tool). Edit Text left with edits pending writes them first; a refused write keeps it, and the promise resolves with it still active. Needs the tool's license feature; refused for a tool the license does not cover.
methodToolssince 1.0.0
Signature
activateTool(tool: ToolName): Promise<void>
Parameters
| Parameter | Type | Description |
|---|---|---|
| tool | ToolName | One of the 26 names of TOOL_NAMES, in the toolbar's order. Two of them are panels rather than tools: 'search' and 'managePages' open their panel and resolve, and activeTool stays what it was — openPanel('search') / openPanel('pages') are the same action by their own name. The exported PANEL_TOOL_NAMES names those two, so a host that marks its buttons pressed from activeTool or toolChanged need not hard-code them. |
Returns
Promise<void>
Throws
INVALID_ARGUMENTfor a name that is no tool or a tool that is off — see isToolEnabled.FEATURE_NOT_LICENSEDfor one the license does not cover.PERMISSION_DENIEDfor one the document's permissions forbid — see toolBlockedReason.UNKNOWN_ERROR(the cause as itscause; or the tool's ownSDKError) for a tool that could not start — nothing of it stays, and the viewer goes back to the resting tool.INVALID_STATEafterdestroy().
Example
TypeScript
await viewer.activateTool('highlight'); await viewer.activateTool('highlight'); // again: back to the resting tool