annotation callbacks not functioning after 2nd document is loaded!

64 views
Skip to first unread message

Danny Mendel

unread,
Jun 7, 2016, 12:27:43 PM6/7/16
to PDFTron WebViewer
https://groups.google.com/forum/#!searchin/pdfnet-webviewer/loadDocument/pdfnet-webviewer/TE9NCEuArvA/vL0ERR1LxWIJ
->
"It looks like the events for the annotation callbacks are not being set when a 2nd document is loaded.

We will try to fix this issue in the next version."

so,
i'm running the same issue with v.2.2.0 latest

please let me know what is the solution as i'm using loadDocument() to load second time and more 
with existing webviewer instance and
a. listen to  annotManager.on('annotationChanged', function (e) {
 if (!e.imported) {
    throttledSave(); //saving annotation via calling saveAnnotations()
}


b. using this code to delete and import server based xfdf annotation file
annotManager.importAnnotationsAsync(sync.syncmap[2].Value, function (list) {
                                        annotManager.drawAnnotationsFromList(list);
                                    });

both a+b work great on first time a document is loaded, 
both a+b never triggered on second...and so forth

Best!
Danny Mendel


Matt Parizeau

unread,
Jun 9, 2016, 2:35:07 PM6/9/16
to PDFTron WebViewer
Hi Danny,

You need to make sure to set your AnnotationManager event handlers in the documentLoaded handler because a new AnnotationManager instance will be created for the new document. If you're saving a reference to the AnnotationManager to use in other places you should also update this reference in documentLoaded.

For example:

var annotManager;

$
(document).on('documentLoaded', function() {
  annotManager
= readerControl.docViewer.getAnnotationManager();
  annotManager
.on('annotationChanged', function() {
    console
.log("annot changed");
 
});
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages