Q: Sending notification when an annotation or a reply is added

24 views
Skip to first unread message

Justin Jung

unread,
Sep 5, 2017, 6:56:16 PM9/5/17
to PDFTron WebViewer
Q: Sending notification when an annotation or a reply is added

A: Here is an example of how you would listen to newly added annotations and replies:

$(document).on('documentLoaded', function() {
  var annotManager = readerControl.docViewer.getAnnotationManager();

  annotManager.on('annotationChanged', function(e, annots, action) {
    if (!e.imported && action === 'add') {
      annots.forEach(function(annot) {
        if (!annot.InReplyTo) {
          console.log('send email to some users');
        }
      });
    }
  });

  annotManager.on('addReply', function(e, reply, parent, root) {
    console.log('send email to ' +  root.Author);
    root.getReplies().forEach(function(reply) {
      console.log('and to ' +  reply.Author);
    });
  });
});
Reply all
Reply to author
Forward
0 new messages