Custom tool to distinguish signatures

129 views
Skip to first unread message

Matt Parizeau

unread,
Aug 15, 2014, 2:44:18 PM8/15/14
to pdfnet-w...@googlegroups.com
Q:

We want the user to be able to write a signature on the document and then be able to distinguish that signature in the XFDF and apply it to the PDF. Is that possible?

A:

You could create a custom tool in WebViewer based on the Free Hand tool and then add a custom attribute to the xfdf to identify that the annotation is a signature. You could use code like the following:
var SignatureCreateTool = function(docViewer) {
   
Tools.FreeHandCreateTool.call(this, docViewer, Annotations.FreeHandAnnotation);
};
SignatureCreateTool.prototype = new Tools.FreeHandCreateTool();
SignatureCreateTool.prototype.complete = function() {
   
if (this.annotation) {
       
this.annotation.isSignature = true;
       
Tools.FreeHandCreateTool.prototype.complete.apply(this, arguments);
   
}
};

var oldFreeHandSerialize = Annotations.FreeHandAnnotation.prototype.serialize;
Annotations.FreeHandAnnotation.prototype.serialize = function() {
   
var el = oldFreeHandSerialize.apply(this, arguments);
   
if (this.isSignature) {
        $
(el).attr('signature', 'true');
   
}
   
return el;
};

$
(document).on('documentLoaded', function() {
    $
("#toolModePicker").append('<li id="annot-button-signature" data-toolmode="AnnotationCreateSignature" title="Signature"><img src="custom_signature_image.png"/></li>');
    readerControl
.toolModeMap['AnnotationCreateSignature'] = SignatureCreateTool;
});

Reply all
Reply to author
Forward
0 new messages