具有可填写字段的动态图章

Dynamic Stamps with fill able fields

本文关键字:动态 写字段      更新时间:2023-09-26

我是杂技演员中这个脚本代码的新手。 我想创建一个动态图章,用户可以在其中输入各种数据,例如公司名称/帐号/批准日期/日期(生成今天的日期)/支付账单(会说"批准,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;
  }
}

这可能与您的 stampName 值("#caseandnumblue")有关。 这应该是 Acrobat 在您创建图章时分配的字母和数字的随机组合,而不是您为图章提供的标签。 您可以通过在 Javascript 调试器中键入以下内容来获取该值:

this.selectedAnnots[0].AP

(按 CTRL-Enter 获取要在 Acrobat 的 Javascript 调试器中执行的代码。那部分让我有点失望。

感谢您在这里发布此内容 - 当我尝试放置自己的作品时,它有很大帮助。 我发现这个 Acrobat 用户教程以及 Adobe 的 JavaScript API 参考 Dialog 对象有助于弄清楚如何在 Acrobat 中构建动态图章对话框。