17 Replies Latest reply on Jun 24, 2014 1:45 PM by Andre Cameron

    dynamic stamp with more then 2 input

    YvanL Level 1

      Hi everyone just wondering if someone could help me out I'm trying to use the already existing code from Case and Exhibit Stamp

      from Tim Parker I believe. what I would like to do is had one more user input if possible so instead of 2 entry there would be 3.

      The input dialog  seems fine it ask all tree question but when the stamp is made there's only the 2 first input on the stamp the 3 one doesn't  show

      I've tried all sorts of way but just can't get it to work. Here's the script if anyone could help me out it be greatly appreciated 

       

      var dialog = {

              afeValue: "",

              managerValue: "",

              glcodeValue: "",

       

       

              commit:function (dialog) { // called when OK pressed

                      var results = dialog.store();

                      this.managerValue = results["txt1"];

                      this.afeValue = results["txt2"];

                      this.glcodeValue = results["txt3"];

              },     

       

       

              description:

              {      

                      name: "stamp Information",    // Dialog box title

                      elements:

                      [      

                              {      

                                      type: "view",

                                      elements:

                                      [      

                                              {      

                                                      name: "Project Manager:",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt1",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 200,

                                                      height: 20

                                              }, 

                                              {      

                                                      name: "Enter AFE Code",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt2",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 200,

                                                      height: 20

                                              },

                                              {      

                                                      name: "Enter GL Code",

                                                      type: "static_text",

                                              },     

                                              {      

                                                      item_id: "txt3",

                                                      type: "edit_text",

                                                      multiline: true,

                                                      width: 200,

                                                      height: 20

                                              },       

                                              {      

                                                      type: "ok_cancel",

                                                      ok_name: "Ok",

                                                      cancel_name: "Cancel"

                                              },     

                                      ]      

                              },     

                      ]      

              }      

      };

       

       

       

       

      if(event.source.forReal && (event.source.stampName == "#ZsaT039jrdNRiBB_8rznLC"))

      {

        if ("ok" == app.execDialog(dialog))

        {

          var cMsg = dialog.managerValue;

          event.value = "\n" + cMsg;

          event.source.source.info.afe = cMsg;

       

          cMsg = "\n" + dialog.afeValue;

          this.getField("afe").value = cMsg;

       

          cMsg = "\n" + dialog.glcodeValue;

          this.getField("glcode").value = cMsg;

       

       

        }

      }

        • 1. Re: dynamic stamp with more then 2 input
          George_Johnson MVP & Adobe Community Professional

          Do you see any errors in the JavaScript console (Ctrl+J)?

          • 2. Re: dynamic stamp with more then 2 input
            YvanL Level 1

            when i start the console i just see the codes no error not sure how to start the codes from the console

            • 3. Re: dynamic stamp with more then 2 input
              George_Johnson MVP & Adobe Community Professional

              Check the console after you apply the stamp.

              1 person found this helpful
              • 4. Re: dynamic stamp with more then 2 input
                YvanL Level 1

                This is what i get for error

                 

                this.getField("glcode") is null

                79:App:Calculate

                TypeError: this.getField("glcode") is null

                79:App:Calculate

                • 5. Re: dynamic stamp with more then 2 input
                  YvanL Level 1

                  thank you for pointing me out the stupid mistake i made

                  for some reason i misspell my field

                  1 person found this helpful
                  • 6. Re: dynamic stamp with more then 2 input
                    Andre Cameron

                    I'm trying to do the same thing, just with 4 fields

                    how did you fix the problem?

                    where am I going wrong?

                     

                    the error message I'm getting is:

                    event.source is null

                    79:Field:Calculate

                    TypeError: event.source is null

                    79:Field:Calculate

                     

                    Here's my code

                     

                     

                    var dialog = {

                            companyValue: "",

                            accountValue: "",

                            approvedValue: "",

                            payValue: "",

                     

                     

                            commit:function (dialog) { // called when OK pressed

                                    var results = dialog.store();

                                    this.companyValue = results["txt1"];

                                    this.accountValue = results["txt2"];

                                    this.approvedValue = results["txt3"];

                                    this.payValue = results["txt4"];

                            },     

                     

                     

                            description:

                            {      

                                    name: "Stamp Information",    // Dialog box title

                                    elements:

                                    [      

                                            {      

                                                    type: "view",

                                                    elements:

                                                    [      

                                                            {      

                                                                    name: "Company name: ",

                                                                    type: "static_text",

                                                            },     

                                                            {      

                                                                    item_id: "txt1",

                                                                    type: "edit_text",

                                                                    multiline: true,

                                                                    width: 300,

                                                                    height: 30

                                                            }, 

                                                            {      

                                                                    name: "Account Number: ",

                                                                    type: "static_text",

                                                            },     

                                                            {      

                                                                    item_id: "txt2",

                                                                    type: "edit_text",

                                                                    multiline: true,

                                                                    width: 300,

                                                                    height: 30

                                                            },

                                                            {      

                                                                    name: "Approved By: ",

                                                                    type: "static_text",

                                                            },     

                                                            {      

                                                                    item_id: "txt3",

                                                                    type: "edit_text",

                                                                    multiline: true,

                                                                    width: 300,

                                                                    height: 30

                                                            },

                                                            {      

                                                                    name: "Pay Bill: ",

                                                                    type: "static_text",

                                                            },     

                                                            {      

                                                                    item_id: "txt4",

                                                                    type: "edit_text",

                                                                    multiline: true,

                                                                    width: 300,

                                                                    height: 30

                                                            },

                                                            {      

                                                                    type: "ok_cancel",

                                                                    ok_name: "Ok",

                                                                    cancel_name: "Cancel"

                                                            },     

                                                    ]      

                                            },     

                                    ]      

                            }      

                    };

                     

                     

                    if(event.source.forReal && (event.source.stampName == "#iCVB3km-jSm7FVdy0PwoWC"))

                    {

                      if ("ok" == app.execDialog(dialog))

                      {

                        var cMsg = dialog.companyValue;

                        event.value = "\n" + cMsg;

                        event.source.source.info.company = cMsg;

                     

                     

                        cMsg = "\n" + dialog.accountValue;

                        this.getField("AccountNumField").value = cMsg;

                     

                     

                        cMsg = "\n" + dialog.approvedValue;

                        this.getField("ApproveByField").value = cMsg;

                     

                     

                        cMsg = "\n" + dialog.payValue;

                        this.getField("PayBillField").value = cMsg;

                      }

                    }

                    • 7. Re: dynamic stamp with more then 2 input
                      George_Johnson MVP & Adobe Community Professional

                      When does that error occur, exactly? If it happens when you're editing the stamp file in Acrobat, it's safe to ignore. It should not be happening when you actually attempt to apply the stamp.

                       

                      Here's what I use to prevent it from happening when I'm editing the calculated field in Acrobat:

                       

                      if (event.source && event.source.forReal && event.source.stampName == "#my_stamp_name") {

                      • 8. Re: dynamic stamp with more then 2 input
                        Andre Cameron Level 1

                        This is happening when I try to use the stamp on a document.


                        link to my pdf

                        • 9. Re: dynamic stamp with more then 2 input
                          George_Johnson MVP & Adobe Community Professional

                          The stamp name in your code doesn't match the actual stamp name. The code should be:

                           

                          if (event.source && event.source.forReal && event.source.stampName == "#zZss48yU6xxuEL_yIq7IjD")

                          • 10. Re: dynamic stamp with more then 2 input
                            Andre Cameron Level 1

                            Thanks alot George that solved my problem.

                            If you don't mind how did you find the stamp name, because I thought it was suppose to be the actual name of the file.

                             

                            Also if I wanted to make drop menus instead

                            e.g. for instance the company name I would like to put the various companies instead of writing it out, what would the a sample code look like?

                             

                             

                            Thanks

                            • 11. Re: dynamic stamp with more then 2 input
                              George_Johnson MVP & Adobe Community Professional

                              Stamp files can contain one or more stamps, one page for each stamp, so it can't be the file name. Pages can be made templates, which is really just a way to give a page a name. Acrobat names stamps automatically when it makes a stamp and you can find it by looking at the name of the template. Exactly how you do this depends on which version of Acrobat you have:

                               

                              Acrobat 9: Advanced > Document Processing > Page Templates

                              Acrobat 10: Tools > Document Processing > Page Templates

                              Acrobat 11: something similar (can't check at the moment)

                               

                              The stamp name will be everything before the "=" character in the template name. The stamp name has to be unique across all stamps on the system, so Acrobat generates a name that is guaranteed to be unique, which is the reason for the seemingly random sequence of characters that it uses. The display name of the stamp is what comes after the "=" character. The "#" character at the beginning is included and important to include for dynamic stamps.

                               

                              When I create a stamp by hand (which is what I normally do), I use a more descriptive stamp name, making sure that it's unique. This helps avoid the problem we're discussing.

                              1 person found this helpful
                              • 12. Re: dynamic stamp with more then 2 input
                                George_Johnson MVP & Adobe Community Professional

                                I just saw your question about dropdowns and don't have time at the moment to provide some sample code, but it is a bit more involved. You can look at the following for a sample: http://www.windjack.com/WindJack/Examples/MultipartFormWizard_Demo2reg.pdf

                                 

                                It's a complicated example since it is a demo of a wizard, but it does include some dropdowns.

                                • 13. Re: dynamic stamp with more then 2 input
                                  Andre Cameron Level 1

                                  Great thanks alot for all the help @George

                                  • 14. Re: dynamic stamp with more then 2 input
                                    Andre Cameron Level 1

                                    So I took a stab at it again @George and just having no luck changing the company name: and approved by: to just a drop down list and getting it working.

                                     

                                    From a beginner standpoint is this something that is really easy to do or very complicated?

                                     

                                    https://www.dropbox.com/s/bc40l7hlxq8046c/iCVB3km-jSm7FVdy0PwoWC.pdf

                                    • 15. Re: dynamic stamp with more then 2 input
                                      try67 MVP & Adobe Community Professional

                                      Creating a dynamic stamp is one of the most advanced scripting tasks in Acrobat.

                                      • 16. Re: dynamic stamp with more then 2 input
                                        George_Johnson MVP & Adobe Community Professional

                                        That link doesn't seem to be working. Custom dialog programming is a bit arcane, and setting up dropdowns can be a bit troublesome, so it's not really something a beginner can pick up easily. But once you have an example like the one I pointed to it gets easier. You might want to get someone to do this for you.

                                        • 17. Re: dynamic stamp with more then 2 input
                                          Andre Cameron Level 1

                                          I took a look at the example, but I can't view the code used to create it.

                                          Thanks for the help though,

                                           

                                          I managed to get the combo boxes to populate correctly, by adding this:

                                           

                                          if (!event.willCommit) {

                                            var f = this.getField("ApproveByField");

                                            f.clearItems();

                                            switch (event.change) {

                                            case "company 1":

                                            f.setItems(["name1", "name2", "name3", "name4"]);

                                            break;

                                            case "company 2":

                                             f.setItems(["name5", "name6", "name7", "name8"]);

                                            break;

                                            case "company 3":

                                            f.setItems(["name9", "name10", "name11", "name12"]);

                                            break;

                                            case "company 4":

                                            f.setItems(["name13", "name14", "name15", "name16"]);

                                            break;

                                            case "company 5":

                                            f.setItems(["name17", "name18", "name19", "name20"]);

                                            break;

                                            case "company 6":

                                            f.setItems(["name21", "name22", "name23", "name24"]);

                                            break;

                                            }

                                          }

                                           

                                           

                                           

                                          I just need to figure out how to put it all together now.

                                          dropbox

                                           

                                          Thanks in advance.