5 Replies Latest reply on Dec 2, 2008 11:24 AM by George_Johnson

    programmatically add signature form fields

    Level 1
      Hello, it was suggested in the other Acrobat forum here that signature fields can be programmatically added to a pdf file.

      I've never scripted in Acrobat so I'm looking for help on how to accomplish this in Acrobat Pro 9. Basically, I want to create a menu item that will allow the author to add two signature fields to a document without having to go through all the standard form creation functions.

      Thanks in advance for your help!
      Jason
        • 1. Re: programmatically add signature form fields
          George_Johnson MVP & Adobe Community Professional
          Here's an article on how to add buttons, but you could easily modify it to add signature fields instead:

          http://www.acrobatusers.com/tutorials/2007/js_add_buttons_to_pdf/

          And here's one on adding a custom menu item:

          http://www.acrobatusers.com/tech_corners/javascript_corner/tips/2006/add_custom_menu_item/

          If you get stuck, post again.

          George
          • 2. Re: programmatically add signature form fields
            Level 1
            Hi George,

            Thanks for the links! I downloaded the SDK for some more help but could use some further direction for getting this done properly.

            function createSig() {
            var loc = [100, 472, 172, 400]; //exact loc tbd on 11x17 doc
            page = this.numPages;
            var sigfield = this.addField("sig", "signature", page, loc);
            }

            Once this is correct, how do I add it to the menu without having to use Acrotools? In the end, I'll probably have 4 or 5 different signature buttons depending on the user.

            Your continued help is greatly appreciated!
            Jason
            • 3. Re: programmatically add signature form fields
              George_Johnson MVP & Adobe Community Professional
              Which page are you attempting to add the signature field to?

              George
              • 4. Re: programmatically add signature form fields
                Level 1
                Hi George,

                It would always go on the last page if there is more than one page. So the author would have a set of drawings, select "user A" from the menu for example and it would place the associated signature box. We have several different documents that require their own custom size/location signature boxes, so this is why I'd just have multiple menu option buttons.

                Thank you!
                Jason
                • 5. Re: programmatically add signature form fields
                  George_Johnson MVP & Adobe Community Professional
                  OK. Page numbers are zero-based (first page is page 0), so the correct code would be:


                  // Determine the last page of this document
                  var page = this.numPages - 1;


                  In the code you use to set up the custom menu item, just call this function by specifying it with the cExec property. Something like:


                  app.addMenuItem({
                      cName: "Add DigSig Field",
                      cParent: "Document",
                      cEnable: "event.rc = event.target;",
                      cExec: "createSig();",
                      nPos: 0
                  });


                  This is really the bare minimum. You might want to add code to check for the existence of the signature field and only add it if it does not exist. A better choice might be to add a submenu to the Tools or Document parent menu.

                  George