Web SDKv1.0.0

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

ParameterTypeDescription
toolToolNameOne 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_ARGUMENT for a name that is no tool or a tool that is off — see isToolEnabled.
  • FEATURE_NOT_LICENSED for one the license does not cover.
  • PERMISSION_DENIED for one the document's permissions forbid — see toolBlockedReason.
  • UNKNOWN_ERROR (the cause as its cause; or the tool's own SDKError) for a tool that could not start — nothing of it stays, and the viewer goes back to the resting tool.
  • INVALID_STATE after destroy().

Example

TypeScript
await viewer.activateTool('highlight');
await viewer.activateTool('highlight'); // again: back to the resting tool

More in PDFViewer