Skip to content

PDF Generation Template Editor

Open-source visual PDF generation engine with customizable templates and developer-friendly APIs.

View on GitHub

Add Annotation Tool ​

You can add annotation tool in the Web PDF Viewer. The following code shows you how to add annotation tools:

javascript
// You can get all tools and set the tool you want.
const toolNames = Object.keys(documentViewer.getToolModeMap());

const inkTool = new Tools.FreeHandCreateTool(documentViewer);
inkTool.setStyles({
  ...documentViewer.getTool(Tools.ToolNames.FREEHAND).defaults,
  StrokeThickness: 5
});
instance.UI.registerTool({
  toolName: 'ink1',
  toolObject: inkTool
});
instance.UI.setToolMode('ink1');