Creating Text Widget Annotations (Acroform Fields)

86 views
Skip to first unread message

Thomas Ganyuk

unread,
Dec 26, 2017, 1:36:02 PM12/26/17
to PDFTron WebViewer
Hello Everyone,

I am trying to add a tool which will place text fields onto the document which can be later filled in by different users. This is my code and it draws a shape but I need it to turn into a fillable field (input box):

var FieldAnnotation = function() {
Annotations.MarkupAnnotation.call(this);
this.Subject = 'Field';
};

FieldAnnotation.prototype = $.extend(new Annotations.TextWidgetAnnotation(new Annotations.Forms.Field('newwww')), {
elementName: 'newEleName',
DateCreated: new Date(),
draw: function(ctx){
ctx.translate(this.X, this.Y);
ctx.beginPath();
ctx.lineTo(this.Width, 0);
ctx.lineTo(this.Width, this.Height);
ctx.lineTo(0, this.Height);
ctx.lineTo(0, 0);
ctx.closePath();
ctx.stroke();
}
});


A link to a sample would be great :)

Thanks!

Matt Parizeau

unread,
Dec 27, 2017, 6:52:12 PM12/27/17
to PDFTron WebViewer
This post shows how to programmatically create a TextWidgetAnnotation https://groups.google.com/d/msg/pdfnet-webviewer/FuHgIrq6UuY/Z_iE70FtCAAJ. Maybe you could have your custom tool create a TextWidgetAnnotation instead of your own custom annotation?

Are you wanting to have the user click and drag to create the size of the text field and when they let go a real text field will be editable on the document? What might work is basing your tool on the RectangleCreateTool and then when the annotation is created you delete the rectangle annotation and add a TextWidgetAnnotation in the same location. Just let us know if you have any more questions about how to implement this.

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages