BUGS: 'annotationChanged' event

56 views
Skip to first unread message

mi...@stellarlibrary.com

unread,
Mar 6, 2018, 4:58:13 PM3/6/18
to PDFTron WebViewer
WebViewer 3.1

STEPS TO REPRODUCE:

var oAnnotMgr = readerControl.docViewer.getAnnotationManager();

1. Instantiate persistent WebViewer instance
1.1. Subscribe to 'annotationChanged' event
1.1.1. oAnnotMgr.on('annotationChanged', function(evt, aAnnotation, sAction) {return console.log('TRIGGERED');});

2. Open document with annotations
2.1. Initialise annotations via oAnnotMgr.importAnnotationsAsync(sXFPDF);

3. readerControl.docViewer.closeDocument();

4. Repeat #2 & #3

This event compounds/increments by each subsequent document open annotations, rather than reflect the current documents annotations.

PS. Historically, this event fires when document loads which is incorrect as they have not modified, we handle that with additional logic by inspecting the XFPDF.hash to see if it actually has changed.

We are not looking to patch this asap, however would be good to have your eyes on this.

mi...@stellarlibrary.com

unread,
Mar 6, 2018, 6:00:33 PM3/6/18
to PDFTron WebViewer
Correction: We are now looking to patch this asap.

Matt Parizeau

unread,
Mar 7, 2018, 12:58:21 PM3/7/18
to PDFTron WebViewer
Hi Mike,

This was a change of behavior in version 3.0. Previously a new AnnotationManager instance was created on every document load, in 3.0 and higher there is one AnnotationManager instance that is reused. Here is the information from the upgrade notes in the what's new section for version 3.0.0 (https://www.pdftron.com/webviewer/demo/whatsnew.html):

Breaking changes:
Now only a single AnnotationManager instance is created even when multiple documents are loaded. This means if you previously added AnnotationManager event handlers inside the documentLoaded event you should move them to the viewerLoaded event otherwise you'll receive an extra event for every new document you load.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

mi...@stellarlibrary.com

unread,
Mar 8, 2018, 1:08:02 PM3/8/18
to PDFTron WebViewer
Hi Matt,

Without attaching event listeners and amending existing event listeners in your library, we see this compounding behaviour.

We attach only 1x listener in $(document).on('viewerLoaded').

Regards

Mike

Matt Parizeau

unread,
Mar 8, 2018, 1:27:03 PM3/8/18
to PDFTron WebViewer
Hi Mike,

I'm having trouble reproducing the compound behavior in WebViewer 3.1. Here are the steps I took:

1. Added a config file with the following code:
$(document).on('viewerLoaded', function() {
  readerControl
.docViewer.getAnnotationManager().on('annotationChanged', function() {
    console
.log('change');
 
});
});

2. Open the developer tools and ran the following code in the console: readerControl.loadDocument('path/to/my.xod')

3. Added, modified and deleted some annotations while observing a single "change" in the console when doing this.

Would you be able to send me a sample with HTML and JS that you're using to reproduce the issue?

Matt Parizeau
Software Developer
PDFTron Systems Inc.

mi...@stellarlibrary.com

unread,
Mar 8, 2018, 6:56:55 PM3/8/18
to PDFTron WebViewer
Hi Matt,

Will send through next week.

The issue with change event is not during annotation CRUD, rather at time of document loading. It fires many times incorrectly, then compounds for each document we open.

Regards

Mike

mi...@stellarlibrary.com

unread,
Mar 12, 2018, 12:59:30 PM3/12/18
to PDFTron WebViewer
Hi Matt,

Just checking for the interim, that you have gone through the steps provided to reproduce the issue.

Regards

Mike

mi...@stellarlibrary.com

unread,
Mar 12, 2018, 12:59:32 PM3/12/18
to PDFTron WebViewer
Hi Matt,

I'm happy to advise you we found a fault with our implementation, events were registering each time via 'documentReady' nested inside 'documentLoaded', the second listener is not required.

Regards

Mike

On Friday, March 9, 2018 at 12:56:55 PM UTC+13, (unknown) wrote:
Reply all
Reply to author
Forward
0 new messages