Adobe Acrobat Javascript Stamp中的默认文本

时间:2017-03-22 04:13:25

标签: javascript adobe acrobat stamp

大家好我看过各种各样的地方,但是我无法弄明白我想要做的就是到达这个地方"注意:"要使用默认文本填充,但可以选择替换它。这是我的代码

  var dialog = {
    AtttoValue: "",
    LSDValue: "",
    AFEValue: "",
    MOCValue:"",
    AcccodeValue:"",
    PrintValue:"",

    commit:function (dialog) { /// called when OK pressed 
            var results = dialog.store();
            this.AtttoValue = results["txt1"];
            this.LSDValue = results["txt2"];
            this.AFEValue = results["txt3"];
            this.MOCValue = results["txt4"];
            this.AcccodeValue = results["txt5"];
            this.PrintValue = results["txt6"];
    },      

    description:
    {       
            name: "stamp Information",    // Dialog box title
            elements:
            [       
                    {       
                            type: "view", 
                            elements:
                            [       
                                    {       
                                            name: "Attention To:",
                                            type: "static_text",
                                    },      
                                    {       
                                            item_id: "txt1", 
                                            type: "edit_text",
                                            multiline: true,
                                            width: 200,
                                            height: 20
                                    },  
                                    {       
                                            name: "Enter LSD:",
                                            type: "static_text",
                                    },      
                                    {       
                                            item_id: "txt2", 
                                            type: "edit_text",
                                            multiline: true,
                                            width: 200,
                                            height: 20
                                    },    
                                    {       
                                            name: "Enter AFE / Cost Code:",
                                            type: "static_text",
                                    },      
                                    {       
                                            item_id: "txt3", 
                                            type: "edit_text",
                                            multiline: true,
                                            width: 200,
                                            height: 20
                                    },
                                    {       
                                            name: "Enter MOC#:",
                                            type: "static_text",
                                    },      
                                    {       
                                            item_id: "txt4", 
                                            type: "edit_text",
                                            multiline: true,
                                            width: 200,
                                            height: 20
                                   }, 
                                   {       
                                            name: "Enter Account Code:",
                                            type: "static_text",
                                    },      
                                    {       
                                            item_id: "txt5", 
                                            type: "edit_text",
                                            multiline: true,
                                            width: 200,
                                            height: 20
                                   }, 
                                     {       
                                            name: "Print Name:",
                                            type: "static_text",
                                    },      
                                      {       
                                            item_id: "txt6", 
                                            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 ==         "#C6nQNxSFN0d4NCJMeJuYYA"))
{
 if ("ok" == app.execDialog(dialog))
{
;var cMsg = dialog.AtttoValue;
;event.value = "\n" + cMsg;
;event.source.source.info.afe = cMsg;

this.getField("LSD").value = "\n" + dialog.LSDValue;

this.getField("AFE").value = "\n" + dialog.AFEValue;

this.getField("MOC").value = "\n" + dialog.MOCValue;

this.getField("Acccode").value = "\n" + dialog.AcccodeValue;    

this.getField("Print").value = "\n" + dialog.PrintValue;


  }

}

非常感谢任何帮助

1 个答案:

答案 0 :(得分:0)

您需要将初始化对象添加到对话框对象。这样的事情......假设“txt1”是你要填充的字段。

{
    initialize: function(dialog) {
        dialog.load({"txt1": "yourDefaultValue" });
    }
}