Re: Saving annotations without hitting the save button

402 views
Skip to first unread message

Richard

unread,
Jul 10, 2014, 5:22:06 AM7/10/14
to pdfnet-w...@googlegroups.com
Hi Matt,

I have found that saveAnnotations methods would sent all of annotations to service.

For my requirement, I suggest to save an annotation after annotation change(include add, update, detelete). But I couldn't get the xfdf string of each annotation.

Could you please tell me how to implement it.

Regards,
Richard

在 2014年5月14日星期三UTC+8上午3时09分33秒,Matt Parizeau写道:
Q:

When in the annotation mode it would be nice if users could save the annotations without explicitly hitting the save button. Is this possible?

A:

There is an event called annotationChanged that is triggered when an annotation is added, deleted or modified. So you could have code similar to the following, that saves annotations after every change:

annotManager.on('annotationChanged', function(e) {
    readerControl.saveAnnotations();
});

You would probably not want the "Annotations Saved" message to appear so you could modify the saveAnnotations function to not display the message.

Alternatively you could use other criteria for when to automatically save, like on a blur event or something similar. Again you would only need to call the saveAnnotations function whenever you wanted to save.

Matt Parizeau

unread,
Jul 10, 2014, 3:29:20 PM7/10/14
to pdfnet-w...@googlegroups.com
Hi Richard,

You could use AnnotationManager's GetAnnotCommand function to get the changed annot's data. You could listen for the annotationChanged event and then call that function there.

annotManager.on('annotationChanged', function(e, annotation, action) {
    var command = annotManager.GetAnnotCommand();
    // send to server
});

Matt Parizeau
Software Developer
PDFTron Systems Inc.

Richard

unread,
Jul 13, 2014, 10:27:22 PM7/13/14
to pdfnet-w...@googlegroups.com
Hi Matt,

Thanks for your help.

Richard

在 2014年7月11日星期五UTC+8上午3时29分20秒,Matt Parizeau写道:

Matt Parizeau

unread,
Nov 15, 2016, 7:05:01 PM11/15/16
to pdfnet-w...@googlegroups.com
Q:

When in the annotation mode it would be nice if users could save the annotations without explicitly hitting the save button. Is this possible?

A:

There is an event called annotationChanged that is triggered when an annotation is added, deleted or modified. So you could have code similar to the following, that saves annotations after every change:

annotManager.on('annotationChanged', function(e) {
    readerControl.saveAnnotations();
});

You would probably not want the "Annotations Saved" message to appear so you could modify the saveAnnotations function to not display the message.

Alternatively you could use other criteria for when to automatically save, like on a blur event or something similar. Again you would only need to call the saveAnnotations function whenever you wanted to save.

You could also call readerControl.exportAnnotations yourself to show your own UI for when the saving happens. See the saveAnnotations function in ReaderControl.js for an example.
Reply all
Reply to author
Forward
0 new messages