Multiple annotationChanged events while UI.loadDocument is called

Product: Apryse PdfTron

Product Version: 10.2.3

Please give a brief summary of your issue:
Multiple annotationChange events fired

Please describe your issue and provide steps to reproduce it:
Everytime I call the loadDocument function on UI, the number of “annotationChanged” events increases when I add an FreeTextAnnotation in a document

Use case: There is a UI.loadDocument function inside a useEffect(), every time I select another document the useEffect runs once and the annotationChanged event should be fired once which happens in the initial document load. But when I load multiple documents one after another, the number of annotationChange events increses by one.

Please provide a link to a minimal sample where the issue is reproducible: A Pen by Subhrajyoti Behera (

1 Like

Hi subhra,

The annotationChanged event is fired every time an annotation is added, modified, or deleted. If a new document has 10 annotations, the event will be fired 10 times.

Since the doc reference changes everytime a new document is uploaded, this will cause the event to be registered again. I’d recommend splitting the 2 functions in 2 useEffect blocks so that annotationChanged doesn’t depend on doc.

I’d also recommend sharing WebViewer instance across components to avoid prop drilling and keep the code cleaner. Please find relevant documentation:

Maggie V.


Hello Maggie,

Thank you for the quick response. I followed what you mentioned and it is working as intended.
Thank you again for the solution


1 Like