Have the "status" property set on annotation when importing XFDF into Acrobat

70 views
Skip to first unread message

Matt Parizeau

unread,
Nov 17, 2014, 3:36:15 PM11/17/14
to pdfnet-w...@googlegroups.com
Q:

Is it possible to import annotations create in WebViewer into a PDF and have the status (e.g. Accepted, Cancelled, Completed, Rejected) be set on the annotation?

A:

Currently status is not changeable from the default WebViewer UI but you could make some customizations to allow this. Basically the status of an annotation is actually represented by a separate reply annotation. So what you could do is when you want to set the status of an annotation run the following code:
var statusAnnot = annotManager.createAnnotationReply(annot);
var popup = $(statusAnnot).data('popup');
popup
.hide();
$
(popup.el).hide();

statusAnnot
.status = 'Accepted';
statusAnnot
.setContents('Accepted by ' + annot.Author);

Then you'll have to override the serialize and deserialize functions for sticky annotations so that the status can be saved and loaded correctly:

var stickySerialize = Annotations.StickyAnnotation.prototype.serialize;
Annotations.StickyAnnotation.prototype.serialize = function(el, pageMatrix) {
    stickySerialize
.apply(this, arguments);

   
if (this.status) {
        $
(el).attr({
            statemodel
: 'Review',
            state
: this.status,
            flags
: 'hidden,nozoom,norotate' // seems to be required to import into Acrobat
       
});
   
}

   
return el;
};

var stickyDeserialize = Annotations.StickyAnnotation.prototype.deserialize;
Annotations.StickyAnnotation.prototype.deserialize = function(el, pageMatrix) {
    stickyDeserialize
.apply(this, arguments);

   
var status = $(el).attr('state');

   
if (status) {
       
this.status = status;
   
}
};

Reply all
Reply to author
Forward
0 new messages