ComPDFKit Web SDK
    Preparing search index...

    Function registerTool

    • Registers a tool with the viewer. The tool can then be activated with setToolMode(toolName) and placed in a header with new UI.Components.ToolButton({ dataElement, toolName }); tool buttons without their own icon or title use buttonImage and tooltip. The last two arguments (mapping custom annotation classes to the tool) are not supported and are ignored with a warning.

      Parameters

      • tool: ToolRegistration

        { toolName, toolObject, buttonImage, buttonName, tooltip, ... }.

      • OptionalannotationConstructor: unknown
      • OptionalcustomAnnotationCheckFunc: unknown

      Returns void

      const { Tools, documentViewer } = instance.Core;
      instance.UI.registerTool({
      toolName: 'MyRectangleTool',
      toolObject: new Tools.RectangleCreateTool(documentViewer),
      buttonImage: 'RectangleTool', // a built-in icon name
      tooltip: 'My rectangle',
      });
      instance.UI.setToolMode('MyRectangleTool');