下面的代码用于 Adobe Reader 中的自定义图章。此代码适用于邮票表中的一行 3 个文本字段。
它的作用:在放置印章时要求用户在 javascript 窗口中输入。提交后,自定义图章表格中的文本字段将填入输入内容。
问题:它在 Adobe Acrobat Pro XI 中适用于所有 3 个字段。但除了 Adobe Reader DC 中的第一个字段外,它无法用于任何其他领域。导致其他 2 个字段为空白。
第一个字段有效的事实意味着我的代码在底部(“这部分!”)都很好。在修复或让我知道使用用户输入定义字段值的另一种方法方面的任何帮助将不胜感激:)
据我所知(PDF JavaScript 在 Adobe Reader DC 但所有其他 Reader 中不起作用)新的 Adobe Reader DC 对 javascript 语法非常严格。
var dialog = {
noz8Value: "",
fa8Value: "",
fl8Value: "",
commit:function (dialog) { // called when OK pressed
var results = dialog.store();
this.noz8Value = results["txt1"];
this.fa8Value = results["txt2"];
this.fl8Value = results["txt3"];
},
description:
{
name: "8 Nozzle Load", // Dialog box title
elements:
[
{
type: "view",
elements:
[
{
name: "1st Nozzle ID: ",
type: "static_text",
},
{
item_id: "txt1",
type: "edit_text",
width: 300,
height: 30
},
{
name: "Fa (kN): ",
type: "static_text",
},
{
item_id: "txt2",
type: "edit_text",
width: 300,
height: 30
},
{
name: "Fl (kN): ",
type: "static_text",
},
{
item_id: "txt3",
type: "edit_text",
width: 300,
height: 30
},
]
},
]
}
};
// THIS PART HERE (below)
//Line below Runs dialog function (prompt window) if stamp is placed down
if(event.source.forReal && (event.source.stampName == "#nozzle"))
{
if ("ok" == app.execDialog(dialog))
{
var cMsg = dialog.noz8Value;
event.value = "\n" + cMsg;
event.source.source.info.noz = cMsg;
var cMsg2 = dialog.fa8Value;
this.getField("fa8Field").value = cMsg2;
var cMsg3 = dialog.fl8Value;
var test1 = this.getField("fl8Field");
test1.value= cMsg3
// Above I tried 3 different ways of linking the user input as the field's `value.`
}
}