从用户获取复选框数据并在Adobe Acrobat中检查动态戳记

时间:2011-11-23 18:52:59

标签: javascript adobe acrobat

我正在Acrobat中构建动态图章。它有5个复选框和三个文本字段。我有正确的文本字段,弹出一个对话框,询问名称,项目,他们填写它,它填写字段。另一个文本框是我动态提取的日期。复选框是麻烦。我知道要检查一下:

var f = this.getField("cb10");
f.checkThisBox(0,true);

我不知道如何在对话框中包含选项并将它们链接到邮票框。 任何帮助非常感谢。

修改

我想出了这个:

    var DiaBox =
{

result:"cancel",
DoDialog: function(){return app.execDialog(this);},
bChk1:false,
bChk2:false,
bChk3:false,
bChk4:false,
bChk5:false,
stredt1:"",
stredt2:"",
initialize: function(dialog)
{
var dlgInit = 
{
"Chk1": this.bChk1,
"Chk2": this.bChk2,
"Chk3": this.bChk3,
"Chk4": this.bChk4,
"Chk5": this.bChk5,
"edt1": this.stredt1,
"edt2": this.stredt2,
};
dialog.load(dlgInit);
},
commit: function(dialog)
{
var oRslt = dialog.store();
this.bChk1 = oRslt["Chk1"];
this.bChk2 = oRslt["Chk2"];
this.bChk3 = oRslt["Chk3"];
this.bChk4 = oRslt["Chk4"];
this.bChk5 = oRslt["Chk5"];
this.byName = oRslt["edt1"];
this.projNum = oRslt["edt2"];
},
description:
{
name: "Stamp",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Check only ONE box:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "check_box",
item_id: "Chk1",
name: "Approved",
},
{
type: "check_box",
item_id: "Chk2",
name: "Approved as Noted - Proceed",
},
{
type: "check_box",
item_id: "Chk3",
name: "Revise and Resubmit",
},
{
type: "check_box",
item_id: "Chk4",
name: "Not a required submittal - not Reviewed",
},
{
type: "check_box",
item_id: "Chk5",
name: "Rejected - Do Not Use",
},
{
type: "static_text",
item_id: "sta1",
name: "Project Number",
alignment: "align_row",
},
{
type: "edit_text",
item_id: "edt1",
char_width: 20,
char_height: 6,
alignment: "align_left",
},
{
type: "static_text",
item_id: "sta2",
name: "Name:",
},
{
type: "edit_text",
item_id: "edt2",
char_width: 20,
alignment: "align_left",
font: "palette",
},
]
},
{
type: "ok_cancel",
},
]
},
]
}
};

// Example Code
DiaBox.bChk1 = false;
DiaBox.bChk2 = false;
DiaBox.bChk3 = false;
DiaBox.bChk4 = false;
DiaBox.bChk5 = false;
DiaBox.stredt1 = "";
DiaBox.stredt2 = "";

if(event.source.forReal && (event.source.stampName == "#bsiloE85pqFs4ntcdBQCMC"))
{
  if ("ok" == app.execDialog(DiaBox))
  {
    var cMsg = DiaBox.byName;
    event.value = "Project # " + cMsg;
    event.source.source.info.exhibit = cMsg;

    cMsg = "By: " + DiaBox.projNum;
    this.getField("byNameField").value = cMsg;

    this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);
    this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);
    this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);
    this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);
    this.getField("cbx5").checkThisBox(0, DiaBox.bChk5);
  }
}

它在Acrobat中运行良好,但在阅读器中,“按名称”字段和复选框不会填充。我无法在阅读器中获得调试器,因此我有一个跟踪问题的问题。谁能看到它可能是什么?

1 个答案:

答案 0 :(得分:0)

由于现在它已经出现在谷歌搜索的顶部,我会告诉你我做了什么,它不完美或优雅,但它的工作原理。

{
name: "Stamp",
elements:
[
{
type: "view",
elements:
[
{
type: "view",
char_height: 10,
elements:
[
{
type: "static_text",
item_id: "stat",
name: "Check only ONE box:",
width: 152,
height: 23,
char_width: 15,
alignment: "align_fill",
font: "dialog",
},
{
type: "check_box",
item_id: "Chk1",
name: "Approved",
},
{
type: "check_box",
item_id: "Chk2",
name: "Approved as Noted - Proceed",
},
{
type: "check_box",
item_id: "Chk3",
name: "Revise and Resubmit",
},
{
type: "check_box",
item_id: "Chk4",
name: "Not a required submittal - not Reviewed",
},
{
type: "check_box",
item_id: "Chk5",
name: "Rejected - Do Not Use",
}
]
},
{
type: "ok_cancel",
},
]
},
]
}
};

// Example Code
//DiaBox.bChk1 = false;
//DiaBox.bChk2 = false;
//DiaBox.bChk3 = false;
//DiaBox.bChk4 = false;
//DiaBox.bChk5 = false;
//DiaBox.stredt1 = "";
//DiaBox.stredt2 = "";

if(event.source.forReal && (event.source.stampName == "#bsiloE85pqFs4ntcdBQCMC"))
{
  if ("ok" == app.execDialog(DiaBox))
  {

    this.getField("cbx1").checkThisBox(0, DiaBox.bChk1);
    this.getField("cbx2").checkThisBox(0, DiaBox.bChk2);
    this.getField("cbx3").checkThisBox(0, DiaBox.bChk3);
    this.getField("cbx4").checkThisBox(0, DiaBox.bChk4);
    this.getField("cbx5").checkThisBox(0, DiaBox.bChk5);
  }
}

if ("ok" == app.execDialog(DiaBox))
  {
    var cMsg = DiaBox.byName;
    event.value = "Project # " + cMsg;
    event.source.source.info.exhibit = cMsg;
  }

将JS框分开,这是我可以捕获图章数据的唯一方法。