0

I'm new to this scripting code in acrobat. and I wanted to create a dynamic stamp where the users inputs various data e.g company name / account number / approved by / date (generates todays date) / pay bill (which would say"approved, N/A,)

from searching the web I found some code here and there and I came up with this: but so far I'm having no luck. what am I doing wrong.

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: "Exhibit 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 == "#caseandnumblue"))
{
  if ("ok" == app.execDialog(dialog))
  {
    var cMsg = dialog.companyValue;
    event.value = "Company\n" + cMsg;
    event.source.source.info.company = cMsg;

    cMsg = "Account\n" + dialog.accountValue;
    this.getField("AccountNumField").value = cMsg;

    cMsg = "Approved\n" + dialog.approvedValue;
    this.getField("ApproveByField").value = cMsg;

    cMsg = "Pay\n" + dialog.payValue;
    this.getField("PayBillField").value = cMsg;
  }
}
user2933380
  • 3
  • 1
  • 3

1 Answers1

1

It might have to do with your stampName value ("#caseandnumblue"). This is supposed to be the random mix of letters and numbers assigned by Acrobat when you create the stamp, not the label you gave the stamp. You can get that value by typing the following into the Javascript Debugger:

this.selectedAnnots[0].AP

(Press CTRL-Enter to get code to execute in Acrobat's Javascript debugger....that part threw me off for a bit.)

Thanks for posting this here - it helped a lot while I was trying to put one of my own work. I found this Acrobat Users tutorial as well as Adobe's JavaScript API Reference for the Dialog object helpful in figuring out how to built a dynamic stamp dialog in Acrobat.

  • Thanks that really helped me out. My next question is how to go about changing the company name to a drop down list to choose from instead of typing it in. Right now I tired to do something like `code` var oCompanyNameField = {"-":None, "Bus & Boat":Bus & Boat, "Magic Bus":Magic Bus, "Music Aquatique":Music Aquatique, "Urban Inc":Urban Inc, "2123632 Ontario Ltd":2123632 Ontario Ltd, "2419017 Ontario Ltd":2419017 Ontario Ltd}; dialog.load({txt1:oCompanyNameField});`code` I'm just having no luck with this. – user2933380 Jun 23 '14 at 20:41