以下代码用于Adobe Reader中的自定义图章。该代码用于邮票表中的3个文本字段。
它的作用:放置图章时在javascript窗口中要求用户输入。提交后,自定义图章表格中的文本字段将填充输入。
问题:它适用于Adobe Acrobat Pro XI中的所有3个字段。但是,除了Adobe Reader DC中的第一个字段以外,它都无法工作。结果其他两个字段为空白。
第一个字段起作用的事实意味着我的代码可以精确到最下面的部分(“ THIS PART HERE!”)。在修复或让我知道使用用户输入定义字段值的另一种方法方面的任何帮助将不胜感激:)
据我所知(PDF JavaScript does not work in Adobe Reader DC but all other Readers),新的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.`
}
}
答案 0 :(得分:0)
我修复了!
没有event.source.source.info.noz = cMsg;该代码有效。较旧的版本运行良好,并且比较宽松。 DC很严格。
if(event.source.forReal && (event.source.stampName == "#nozzle"))
{
if ("ok" == app.execDialog(dialog))
{
var cMsg = dialog.noz8Value;
event.value = "\n" + cMsg;
var cMsg2 = dialog.fa8Value;
this.getField("fa8Field").value = cMsg2;
var cMsg3 = dialog.fl8Value;
var test1 = this.getField("fl8Field");
test1.value= cMsg3
}
}