PDF Javascript for Custom Stamp在Adobe Reader DC中不起作用
以下代码用于Adobe Reader中的自定义图章。此代码用于stamp表中包含3个文本字段的一行。
它的作用:在放置图章时,要求用户在javascript窗口中输入。提交后,自定义图章的表中的文本字段将使用输入填充。
问题:它在Adobe Acrobat Pro XI中适用于所有3个字段。但对于Adobe Reader DC中除第一个字段以外的任何字段都不起作用。导致其他2个字段为空。
第一个字段可以工作的事实意味着我的代码直到底部都是正常的(“这里有这个部分!”)。如果这里能帮助我修复或让我知道另一种使用用户输入定义字段值的方法,我们将不胜感激:)
据我所知( 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.`
}
}
转载请注明出处:http://www.txqp3.com/article/20230526/1650642.html