How to make Annotation Rectangle tool to enable drawing based on click of annotate button

Hello rakshitha_r,

If you want to hide all the tools except the rectangular annotation tool, you can hide the elements like so from the WebViewer constructor or programatically like you have:

On your annotate button, you can bind a ‘click’ event to set the tool mode:
https://pdfjs.express/api/Core.DocumentViewer.html#setToolMode
and the toolNames are available here: PDFJS Express WebViewer Namespace: Tools

  document.getElementById('annotate-button').addEventListener('click', async (e) => {
    instance.UI.setToolMode(instance.Core.Tools.ToolNames.RECTANGLE)
  })

And if you would like to customize the style you can follow the forum guide here:

Best Regards,
Kevin Kim


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here