Creating annotations with a single click

187 views
Skip to first unread message

Matt Parizeau

unread,
Aug 30, 2016, 3:36:29 PM8/30/16
to pdfnet-w...@googlegroups.com
Q:

I want to create an annotation of a fixed size with a single click instead of requiring a click/drag to set the width and height. Is this possible?

A:

The following code is based on the custom diamond sample and should be able to be adjusted for other types of annotations, including custom ones.

var CustomDiamondCreateTool = function(docViewer) {
    Tools.GenericAnnotationCreateTool.call(this, docViewer, CustomDiamondAnnotation);
};
CustomDiamondCreateTool.prototype = new Tools.GenericAnnotationCreateTool();
CustomDiamondCreateTool.prototype.mouseLeftDown = function() {
    Tools.AnnotationSelectTool.prototype.mouseLeftDown.apply(this, arguments);
};
CustomDiamondCreateTool.prototype.mouseMove = function() {
    Tools.AnnotationSelectTool.prototype.mouseMove.apply(this, arguments);
};
CustomDiamondCreateTool.prototype.mouseLeftUp = function(e) {
    var annotation;
    Tools.GenericAnnotationCreateTool.prototype.mouseLeftDown.call(this, e);
    if (this.annotation) {
        this.annotation.Width = 100;
        this.annotation.Height = 100;
        annotation = this.annotation;
    }
    Tools.GenericAnnotationCreateTool.prototype.mouseLeftUp.call(this, e);
    if (annotation) {
        readerControl.docViewer.getAnnotationManager().redrawAnnotation(annotation);
    }
};
Reply all
Reply to author
Forward
0 new messages