Getting an event for selection of area

Which product are you using?
PDF.js Express Viewer

PDF.js Express Version

UI version ‘8.7.0’
Core version ‘8.7.4’
webviewer.min.js ‘8.7.4’

Detailed description of issue
When in selection mode in the viewer, you can draw a box around an area of the pdf. How do I get an event for when this happens along with the coordinates of the selection rectangle? I’ve searched the site and combed the documentation and haven’t been able to find anything.


Expected behaviour
An easy-to-find, documented event.

Does your issue happen with every document, or just one?

Link to document

Code snippet

Hello david,

Thank you for raising this,

You can get the area by listening to the mouseLeftDown and mouseLeftUp events like so

const {documentViewer, Tools} = instance.Core
documentViewer.addEventListener("mouseLeftDown", (e)=>{
   const startLocation = documentViewer.getTool(Tools.ToolNames.EDIT).getMouseLocation(e);

documentViewer.addEventListener("mouseLeftUp", (e)=>{
   const endLocation = documentViewer.getTool(Tools.ToolNames.EDIT).getMouseLocation(e);

Best regards,