Expand my Community achievements bar.

How to remove an ink signature with Javascript

Avatar

Former Community Member

Hello,

I created a form with the capability to sign it with an "ink signature".

I would like to add a button on top of my form to remove any ink signature. It's possible to remove them with a right click and delete, but because we will use the form with a tablet it's better to have a button that will remove them automatically.

I tried a lot of things in javascript but without success. Any ideas ?

Thanks in advance for your help

4 Replies

Avatar

Former Community Member

As you may or may not know, an "Ink" signature is simply an annotation (pencil tool) used to represent a hand written signature.  You can Acrobat Javascript to delet annotations.  I added the following JavaScript to a button on a PDF to "delete" the annotation.

var annots = this.getAnnots({ nPage:0 });

for (var i = 0; i < annots.length; i++)

        if (annots[i].type == "Ink")

               annots[i].destroy();

I also attached the sample form.

Hope this helps.

Steve

Avatar

Former Community Member

Hello,

Thanks for your quick reply.

I tried your piece of code but i got the following error message :

"this.getAnnots is not a function"

It is consistent with what i can see in livecycle. I do not see this method in the list of possible properties/methods assigned to "this".

I read the documentation and saw that this method is assigned to the object "doc". I tried to replace "this" by "doc" and then app.doc (i saw an example in internet) but unfortunately the syntax is not recognised (error message : doc is not defined).

Thanks,

Johnny

Avatar

Former Community Member

Hi,

I did some progress

I do not have any errors anymore with the following syntax : var annots = event.target.getAnnots({nPage:1});  --> (event.target instead of doc)

but i got the message "annots has no properties" now. FYI i have the same error message with your form in attachement.

In designer, i do not see any properties/methods after event.target.

Something else i have to declare somewhere ?

Thanks,

Johnny

Avatar

Former Community Member

Hi,

Finally it is ok. The error i mentionned above is triggered when there is no signature.

I just added a test. The final code is :

var annots = event.target.getAnnots({nPage:0});

if (annots != null) {

     for (var i=0; i < annots.length; i++) {

          if (annots[i].type == "Ink") { annots[i].destroy(); }

     }

}

Thanks a lot for your help.

Regards,

Johnny