How to write Listener to get the value of an area/perimeter measurement

Which product are you using?

PDF.js Express Version
PDF.js Express Plus

Detailed description of issue
I need to get the area measurements I draw on the plan to store in table. Also I should be able to load the stored measurements on the plan. How can i achieve this?

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

Does your issue happen with every document, or just one?
{Answer here}

Link to document
{Provide a link to the document in question if possible}

Code snippet
{Provide a relevant code snippet}

Hello sachin,

Depending on when you want to get the area (on annotation added, or on annotation changed) it can change the event you listen to, but generally you can do:

instance.Core.annotationManager.addEventListener('annotationChanged', (annots, action, info) => {
  if(action === 'modify') {
   annots[0].getContents() // get the area (the contents)
  }

})

Let me know if this works for you.

Best regards,
Tyler

Sorry to bother, Can I have sample working code of this? not just a snippet

I am not getting it added correctly with the demo (measument)

Thanks

Hello sachin,

This code snippet is easily added to one of our samples, just paste it into the WebViewer instance.

We have a react sample here:

Best regards,
Tyler

OK, will check now

Just wanted to know how to get user measured value and send it to db (Our webapp in flutter and passing values to backend using APIs

Hope its clear now

Hello sachin,

The getContents() is the API that gets the value.

Best regards,
Tyler