2013-10-29 87 views
0

我是新來的這個腳本代碼在雜技演員。我想創建一個動態的郵票,其中用戶輸入各種數據,例如公司名稱/帳號/批准/日期(生成今天的日期)/支付帳單(這將說「批准,N/A,)可填充字段的動態郵票

從在網上搜索,我發現了一些代碼在這裏和那裏,我想出了這個: 但到目前爲止我沒有運氣什麼我做錯了

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; 
    } 
} 

回答

1

它可能與你的stampName價值的事情。 (「#caseandnumblue」)。這應該是Acrobat在創建郵票時指定的字母和數字的隨機組合,而不是您爲郵票添加的標籤。您可以通過在Javascript調試器中輸入以下內容來獲取該值:

this.selectedAnnots[0].AP 

(按Ctrl + Enter以獲取代碼在Acrobat的JavaScript調試器來執行....這部分把我關了一下。)

感謝在這裏張貼這一點 - 它幫助了很多,而我試圖把我自己的工作之一。我發現this Acrobat Users tutorial以及Adobe's JavaScript API Reference for the Dialog object有助於理解如何在Acrobat中構建動態戳記對話框。

+0

謝謝,真的幫了我。我的下一個問題是如何將公司名稱更改爲下拉列表以供選擇,而不是將其輸入。現在,我厭倦了執行諸如'code' var oCompanyNameField = {「 - 」:None,「Bus&船「:巴士和船,」魔法巴士「:魔法巴士,」音樂水族「:音樂Aquatique,」城市公司「:城市公司,」2123632安大略有限公司「:2123632安大略有限公司,」2419017安大略有限公司「:2419017 Ontario Ltd }; dialog.load({txt1:oCompanyNameField});'code'我只是沒有這個運氣。 – user2933380