4 Replies Latest reply on Jul 21, 2011 1:12 AM by jbx028

    How to remove an ink signature with Javascript

    jbx028

      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

        • 1. Re: How to remove an ink signature with Javascript
          SForrest96 Level 4

          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

          • 2. Re: How to remove an ink signature with Javascript
            jbx028 Level 1

            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

            • 3. Re: How to remove an ink signature with Javascript
              jbx028 Level 1

              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

              • 4. Re: How to remove an ink signature with Javascript
                jbx028 Level 1

                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